Skip to content

Instantly share code, notes, and snippets.

@oligazar
Last active August 5, 2021 11:34
Show Gist options
  • Save oligazar/779a0e66567f187aa45a47a575ab64f3 to your computer and use it in GitHub Desktop.
Save oligazar/779a0e66567f187aa45a47a575ab64f3 to your computer and use it in GitHub Desktop.
parseJson() {
try {
return Login.fromJson(json.decode(result.body));
} on FormatException catch (e) { // catching an exception according to it's type
return Future.error(InvalidDataError(e.message));
} on ParseException {
return Future.error(InvalidDataError());
} catch (_) {
return Future.error(InvalidDataError());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment