Update for backwards compatibility

This commit is contained in:
Tobe O 2018-07-09 10:27:31 -04:00
parent a30ad98ee0
commit d60bc4faf2
3 changed files with 12 additions and 5 deletions

View file

@ -1,2 +1,5 @@
# 1.0.0+2
* Added a backwards-compatible way to cast the `errors` List.
# 1.0.0+1
* Dart 2 updates.

View file

@ -46,10 +46,14 @@ class AngelHttpException implements Exception {
}
factory AngelHttpException.fromMap(Map data) {
return new AngelHttpException(null,
statusCode: (data['status_code'] ?? data['statusCode']) as int,
message: data['message']?.toString(),
errors: (data['errors'] as Iterable)?.cast<String>()?.toList());
return new AngelHttpException(
null,
statusCode: (data['status_code'] ?? data['statusCode']) as int,
message: data['message']?.toString(),
errors: data['errors'] is Iterable<String>
? ((data['errors'] as Iterable<String>).toList())
: <String>[],
);
}
factory AngelHttpException.fromJson(String str) =>

View file

@ -1,5 +1,5 @@
name: angel_http_exception
version: 1.0.0+1
version: 1.0.0+2
description: Angel's HTTP exception class.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/http_exception