Skip to main content

angel3_http_exception 10.0.0 copy "angel3_http_exception: ^10.0.0" to clipboard
angel3_http_exception: ^10.0.0 copied to clipboard

Exception class that can be serialized to JSON and serialized to clients.

Angel3 Http Exception #

Pub Version (including pre-releases) Null Safety Discord License

Exception class that can be serialized to JSON and serialized to clients. Angel3's HTTP exception class.

Installation #

In your pubspec.yaml:

dependencies:
  angel3_http_exception: ^10.0.0

Usage #

Throw an AngelHttpException from a handler, and Angel3 sends its status and message to the client:

import 'package:angel3_http_exception/angel3_http_exception.dart';

void main() {
  try {
    throw AngelHttpException.notFound(message: "Can't find that page!");
  } on AngelHttpException catch (e) {
    print(e.statusCode); // 404
    print(e.toJson()); // The JSON sent to the client
  }

  // An error of a response, as a client reads it:
  var e = AngelHttpException.fromMap({'status_code': 400, 'message': 'Bad'});
  print(e.statusCode); // 400
}
0
likes
160
points
1.16k
downloads

Documentation

API reference

Publisher

verified publisherdukefirehawk.com

Weekly Downloads

Exception class that can be serialized to JSON and serialized to clients.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (license)

More

Packages that depend on angel3_http_exception