You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Provide a method to get GraphQLError as Js.Exn.t #257
Error reporting code that accepts a Js.Exn.t can't directly accept a GraphQLError. Adding an asJsExn method to GraphQLError.res could simplify code that deals with errors :) external asJsExn : t => Js.Exn.t = "%identity" should probably do the trick :D (this only holds from GraphQLError -> Error)
This makes sense to me @Kingdutch! The only other question I have for your use case is whether or not accessing originalError off of the GraphQLError is good enough for this use case. We do provide a binding to that already, so you should always be able to access originalError off of a GraphQLError — though it is an option type, so its presence isn't guaranteed even if an error is encountered.
All that being said, I could see this being useful. I'd be happy to accept a PR if you want to include what you have above on the binding for GraphQLError.
I think the fact that originalError can be undefined would make it not enough (since sometimes we have a GraphQLError but then couldn't log the originalError). Additionally I think for logging purposes (which is mostly why I requested this) the extra information about where in the GraphQL schema the error occurred can be very useful.
Activity
parkerziegler commentedon Apr 5, 2021
This makes sense to me @Kingdutch! The only other question I have for your use case is whether or not accessing
originalErroroff of theGraphQLErroris good enough for this use case. We do provide a binding to that already, so you should always be able to accessoriginalErroroff of aGraphQLError— though it is anoptiontype, so its presence isn't guaranteed even if an error is encountered.All that being said, I could see this being useful. I'd be happy to accept a PR if you want to include what you have above on the binding for
GraphQLError.Kingdutch commentedon Dec 15, 2021
Hi @parkerziegler I realised I never got back to this.
I think the fact that
originalErrorcan beundefinedwould make it not enough (since sometimes we have a GraphQLError but then couldn't log the originalError). Additionally I think for logging purposes (which is mostly why I requested this) the extra information about where in the GraphQL schema the error occurred can be very useful.