Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dart2]: improved error reporting #1006

Merged
merged 3 commits into from
Sep 10, 2018
Merged

[Dart2]: improved error reporting #1006

merged 3 commits into from
Sep 10, 2018

Conversation

ircecho
Copy link
Contributor

@ircecho ircecho commented Sep 10, 2018

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.3.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

@ircecho (2017/07) @swipesight (2018/09)

Description of the PR

(details of the change, additional tests that have been done, reference to the issue for tracking, etc)

Fixed catch in ApiClient to properly display exceptions and errors.

Original error is gobbled, overshadowed by exception in catch block.

Unhandled exception:
type '_TypeError' is not a subtype of type 'Exception'
#0      ApiClient._deserialize (file:///.../lib/api_client.dart:226:78)
#1      ApiClient.deserialize (file:///.../lib/api_client.dart:238:12)
...

becomes

type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Map<String, Map<String, dynamic>>'
#0      new ArticleRepresentation.fromJson (file:///.../lib/model/article_representation.dart:85:59)
#1      ArticleRepresentation.listFromJson.<anonymous closure> (file:///.../lib/model/article_representation.dart:128:87)
...

Original error is visible properly.

@wing328
Copy link
Member

wing328 commented Sep 10, 2018

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@ircecho
Copy link
Contributor Author

ircecho commented Sep 10, 2018

@wing328 Fixed.

@wing328
Copy link
Member

wing328 commented Sep 10, 2018

@ircecho looks good now.

May I know if you've dartfmt installed locally in your machine? If yes, can you run the following to setup an environment variable:

export DART_FMT_PATH=/usr/local/bin/dart

and then update the samples again so that the Dart code will have better format.

(This is a new feature we added recently. Please let us know if you've any feedback)

@wing328 wing328 added this to the 3.3.0 milestone Sep 10, 2018
@ircecho
Copy link
Contributor Author

ircecho commented Sep 10, 2018

@wing328 Fixed.

My only suggestion to this feature would be to use dartfmt automatically, if it is available in the path. I thought that was the case which is why I did not bother to check. Anyways, now the formatting should be fine.

@wing328
Copy link
Member

wing328 commented Sep 10, 2018

@ircecho thanks for the suggestion. Later we may update the logic to search for dartfmt in the path (Windows, Mac, Linux) and use it automatically if found.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@wing328 wing328 merged commit 6a1e560 into OpenAPITools:master Sep 10, 2018
jaumard pushed a commit to jaumard/openapi-generator that referenced this pull request Sep 21, 2018
* fix[dart]: improved error reporting

* rebuilt dart2 petstore

* rebuilt dart2 petstore with dartfmt
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
* fix[dart]: improved error reporting

* rebuilt dart2 petstore

* rebuilt dart2 petstore with dartfmt
@wing328 wing328 changed the title fix[dart2]: improved error reporting [Dart2]: improved error reporting Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants