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

Error maps from the API return as [object Object] #39

Closed
timhwang21 opened this issue Mar 19, 2019 · 2 comments
Closed

Error maps from the API return as [object Object] #39

timhwang21 opened this issue Mar 19, 2019 · 2 comments

Comments

@timhwang21
Copy link

Seems related to #20 and #29. Also related to phoenixframework/phoenix#3323.

It seems like the various createFooError(errorMessage)s and the various upstream handlers all expect errorMessage to be a string. If my API returns a map instead we get [object Object].

In the other ticket I filed, I post a solution for preprocessing the error message into a string. However, I was wondering if it's reasonable to just check for stringiness in this library, and call JSON.serialize on the message if it's not a string?

A simple example would be changing createRequestError() to be:

const createRequestError = message =>
  new Error(`request: ${typeof message === 'string' ? JSON.stringify(message) : message}`)

(Would obviously benefit from more abstraction!)

@mgtitimoli
Copy link
Member

Message must be string by spec.

We could consider adding support to extensions.

@mgtitimoli
Copy link
Member

Duplicate of #29 (Let's follow the discussion there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants