From 6a1e560540e1178bf81ae593b05e3a2d565e97b8 Mon Sep 17 00:00:00 2001 From: ircecho Date: Mon, 10 Sep 2018 18:14:50 +0200 Subject: [PATCH] fix[dart2]: improved error reporting (#1006) * fix[dart]: improved error reporting * rebuilt dart2 petstore * rebuilt dart2 petstore with dartfmt --- .../main/resources/dart2/api_client.mustache | 2 +- .../openapi/lib/api/pet_api.dart | 12 ++++++++---- .../openapi/lib/api/store_api.dart | 3 ++- .../openapi/lib/api/user_api.dart | 18 ++++++++++++------ .../openapi/lib/api_client.dart | 2 +- .../lib/api/pet_api.dart | 12 ++++++++---- .../lib/api/store_api.dart | 3 ++- .../lib/api/user_api.dart | 18 ++++++++++++------ .../openapi-browser-client/lib/api_client.dart | 2 +- .../dart2/openapi/lib/api/pet_api.dart | 12 ++++++++---- .../dart2/openapi/lib/api/store_api.dart | 3 ++- .../dart2/openapi/lib/api/user_api.dart | 18 ++++++++++++------ .../petstore/dart2/openapi/lib/api_client.dart | 2 +- 13 files changed, 70 insertions(+), 37 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache index 9b83baf71dd..a3cd3c2463b 100644 --- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache @@ -70,7 +70,7 @@ class ApiClient { } } } - } catch (e, stack) { + } on Exception catch (e, stack) { throw ApiException.withInner(500, 'Exception during deserialization.', e, stack); } throw ApiException(500, 'Could not find a suitable class for deserialization'); diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart index 0c625c2b04a..83af6ca8e62 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/pet_api.dart @@ -41,7 +41,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -85,7 +86,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -265,7 +267,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -319,7 +322,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart index 5f88bf5ac99..3fc1364a102 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/store_api.dart @@ -43,7 +43,8 @@ class StoreApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart index 94b245a5609..52202df0ea4 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api/user_api.dart @@ -41,7 +41,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -82,7 +83,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -123,7 +125,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -166,7 +169,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -299,7 +303,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -345,7 +350,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart index 016e939e55d..d0db1fd65ec 100644 --- a/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/flutter_petstore/openapi/lib/api_client.dart @@ -65,7 +65,7 @@ class ApiClient { } } } - } catch (e, stack) { + } on Exception catch (e, stack) { throw ApiException.withInner( 500, 'Exception during deserialization.', e, stack); } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart index 0c625c2b04a..83af6ca8e62 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/pet_api.dart @@ -41,7 +41,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -85,7 +86,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -265,7 +267,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -319,7 +322,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart index 5f88bf5ac99..3fc1364a102 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/store_api.dart @@ -43,7 +43,8 @@ class StoreApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart index 94b245a5609..52202df0ea4 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api/user_api.dart @@ -41,7 +41,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -82,7 +83,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -123,7 +125,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -166,7 +169,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -299,7 +303,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -345,7 +350,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart index 72a7c0f345b..acf873a63b2 100644 --- a/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi-browser-client/lib/api_client.dart @@ -65,7 +65,7 @@ class ApiClient { } } } - } catch (e, stack) { + } on Exception catch (e, stack) { throw ApiException.withInner( 500, 'Exception during deserialization.', e, stack); } diff --git a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart index 0c625c2b04a..83af6ca8e62 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart @@ -41,7 +41,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -85,7 +86,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -265,7 +267,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -319,7 +322,8 @@ class PetApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart index 5f88bf5ac99..3fc1364a102 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart @@ -43,7 +43,8 @@ class StoreApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart index 94b245a5609..52202df0ea4 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart @@ -41,7 +41,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -82,7 +83,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -123,7 +125,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -166,7 +169,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -299,7 +303,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } @@ -345,7 +350,8 @@ class UserApi { if (response.statusCode >= 400) { throw new ApiException(response.statusCode, response.body); - } else if (response.body != null) {} else { + } else if (response.body != null) { + } else { return; } } diff --git a/samples/client/petstore/dart2/openapi/lib/api_client.dart b/samples/client/petstore/dart2/openapi/lib/api_client.dart index 016e939e55d..d0db1fd65ec 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_client.dart @@ -65,7 +65,7 @@ class ApiClient { } } } - } catch (e, stack) { + } on Exception catch (e, stack) { throw ApiException.withInner( 500, 'Exception during deserialization.', e, stack); }