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

Don't Understand to Get Error Message #1249

Closed
rrifafauzikomara opened this issue Oct 16, 2022 · 4 comments
Closed

Don't Understand to Get Error Message #1249

rrifafauzikomara opened this issue Oct 16, 2022 · 4 comments
Assignees
Labels
dart client Issue relates mainly to the standalone dart client enhancement New feature or request
Projects
Milestone

Comments

@rrifafauzikomara
Copy link

Hi, I have a question about how to get real error message.

I have print the error by default like below.

      print('Rifa 1: ${error}'); // from OperationException
      print('Rifa 2: ${error?.linkException}'); // from LinkException

And this is the result for above code.

flutter: Rifa 1: OperationException(linkException: ServerException(originalException: null, parsedResponse: Response(data: null, errors: [GraphQLError(message: Token has expired., locations: null, path: null, extensions: null)], context: Context({ResponseExtensions: Instance of 'ResponseExtensions'}), response {errors: [{errorType: UnauthorizedException, message: Token has expired.}]})), graphqlErrors: [])
flutter: Rifa 2: ServerException(originalException: null, parsedResponse: Response(data: null, errors: [GraphQLError(message: Token has expired., locations: null, path: null, extensions: null)], context: Context({ResponseExtensions: Instance of 'ResponseExtensions'}), response {errors: [{errorType: UnauthorizedException, message: Token has expired.}]}))

As you can see above, the error is nested. But the point of error is Token has expired.

My question is how to print the Token has expired message only?

And also how to get status code of every error? As you can see above no status code printed.

@vincenzopalazzo vincenzopalazzo self-assigned this Oct 16, 2022
@vincenzopalazzo vincenzopalazzo added enhancement New feature or request dart client Issue relates mainly to the standalone dart client labels Oct 16, 2022
@vincenzopalazzo
Copy link
Collaborator

You should be able to unwrap the exception, but this looks tricky and a smell from an app developer's point of view.

I will work on it to improve this use case, thanks to report it

@vincenzopalazzo vincenzopalazzo added this to To do in v5.2.0 via automation Oct 16, 2022
@vincenzopalazzo vincenzopalazzo added this to the v5.2.0 milestone Oct 16, 2022
@Mohdx
Copy link

Mohdx commented Oct 19, 2022

Hello, I'm finding it confusing why OperationException class the graphqlErrors list is empty

I'm testing to throw exception on purpose (for examle "mobile" I change it to "mobil")
image

error: OperationException(linkException: ServerException(originalException: null, parsedResponse: Response(data: null, errors: [GraphQLError(message: Variable "$mobile" is not defined by operation "SignIn"., locations: [ErrorLocation(line: 3, column: 18), ErrorLocation(line: 1, column: 1)], path: null, extensions: {category: graphql}), GraphQLError(message: Variable "$mobil" is never used in operation "SignIn"., locations: [ErrorLocation(line: 1, column: 17)], path: null, extensions: {category: graphql})], context: Context({ResponseExtensions: Instance of 'ResponseExtensions'}), response {errors: [{message: Variable "$mobile" is not defined by operation "SignIn"., extensions: {category: graphql}, locations: [{line: 3, column: 18}, {line: 1, column: 1}]}, {message: Variable "$mobil" is never used in operation "SignIn"., extensions: {category: graphql}, locations: [{line: 1, column: 17}]}]})), graphqlErrors: [])

But on GraphQL website the list of errors is not empty
image

@vincenzopalazzo
Copy link
Collaborator

looks like it is not a graphql error, and also you can not expect to have the same result inside the playground, try with curl!

In addition, these kind of error are some things that we want to improve and throw a generic error, with the possibility to look inside each single one

@vincenzopalazzo
Copy link
Collaborator

closing this in favor of this #1270

We can just improve the error handling

v5.2.0 automation moved this from To do to Done Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart client Issue relates mainly to the standalone dart client enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants