diff --git a/packages/http_exception/lib/angel_http_exception.dart b/packages/http_exception/lib/angel_http_exception.dart index b38d854e..8ccd34dc 100644 --- a/packages/http_exception/lib/angel_http_exception.dart +++ b/packages/http_exception/lib/angel_http_exception.dart @@ -15,22 +15,20 @@ class AngelHttpException implements Exception { final List errors = []; /// The cause of this exception. - String? message; + String message; /// The [StackTrace] associated with this error. StackTrace? stackTrace; /// An HTTP status code this exception will throw. - int? statusCode; + int statusCode; AngelHttpException(this.error, {this.message = '500 Internal Server Error', this.stackTrace, this.statusCode = 500, List errors = const []}) { - if (errors != null) { - this.errors.addAll(errors); - } + this.errors.addAll(errors); } Map toJson() { @@ -52,8 +50,8 @@ class AngelHttpException implements Exception { factory AngelHttpException.fromMap(Map data) { return AngelHttpException( null, - statusCode: (data['status_code'] ?? data['statusCode']) as int?, - message: data['message']?.toString(), + statusCode: (data['status_code'] ?? data['statusCode'] ?? 500) as int, + message: data['message']?.toString() ?? 'Internal Server Error', errors: data['errors'] is Iterable ? ((data['errors'] as Iterable).map((x) => x.toString()).toList()) : [],