From d60bc4faf238e4e1e0227067d82388090e6924e0 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Mon, 9 Jul 2018 10:27:31 -0400 Subject: [PATCH] Update for backwards compatibility --- CHANGELOG.md | 3 +++ lib/angel_http_exception.dart | 12 ++++++++---- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cc9188..59f19f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. \ No newline at end of file diff --git a/lib/angel_http_exception.dart b/lib/angel_http_exception.dart index dd4d2f5f..1735936d 100644 --- a/lib/angel_http_exception.dart +++ b/lib/angel_http_exception.dart @@ -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()?.toList()); + return new AngelHttpException( + null, + statusCode: (data['status_code'] ?? data['statusCode']) as int, + message: data['message']?.toString(), + errors: data['errors'] is Iterable + ? ((data['errors'] as Iterable).toList()) + : [], + ); } factory AngelHttpException.fromJson(String str) => diff --git a/pubspec.yaml b/pubspec.yaml index e9ba2aa7..939cf21b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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 homepage: https://github.com/angel-dart/http_exception