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 handling #5

Open
moltar opened this issue Feb 1, 2018 · 7 comments
Open

Error handling #5

moltar opened this issue Feb 1, 2018 · 7 comments

Comments

@moltar
Copy link

moltar commented Feb 1, 2018

It appears that error handling is broken. The HTTP status is returned in statusCode attribute, rather than status for errors coming from GraphQL middleware.

response.status(error.status)

But, on top of that, I am questioning the need to handle errors there at all. Why not just let the error bubble up and be dealt with by an exceptions handler (app/Exceptions/Handler.js), which does need to be user-defined, but maybe add instructions for that.

@ammezie
Copy link
Owner

ammezie commented Feb 1, 2018

I will look into that once I'm chanced. In the meantime you can send PR to this effect.

@moltar
Copy link
Author

moltar commented Feb 1, 2018

I can do it, I am just not sure I am right with my assumptions. I am new to Adonis.

@kevyworks
Copy link

@ammezie Heads Up: I guess you need to wait for AdonisJS v4.1 which is a breaking changes for exceptions.

Reference: adonisjs/core#718
Tagged: v4.1

@ammezie
Copy link
Owner

ammezie commented Feb 6, 2018

Alright. Thanks for pointing that out.

@antwaanh
Copy link

antwaanh commented Mar 4, 2018

Hi,

Does anyone have and example of how to handle errors?
Currently I'm attempting to return them in a resolve method.

Ex.

    resolve: async (root, { input }, context) => {
      const rules = { email: 'required|email|unique:users' }
      const validation = await validate(input, rules)
      console.log(validation)
      if (validation.fails()) {
        throw new Error('Test')
      }

      return await User.create(input)
    }
[ { message: 'e.hasOwnProperty is not a function',
    field: 'email',
    validation: 'ENGINE_EXCEPTION' },
  message: 'undefined: 1101e897-ea60-407b-b259-28a159c234c0' ]
Error: [object Object]
    at asErrorInstance (/Users/antwaan/Sites/adonisgql/node_modules/graphql/execution/execute.js:545:43)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)

Thanks!

@ammezie
Copy link
Owner

ammezie commented Mar 6, 2018

@moltar still working on a PR on this? Want to know so as to avoid duplicate efforts.

@moltar
Copy link
Author

moltar commented Mar 6, 2018

@ammezie No, not working on this.

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

4 participants