Giter VIP home page Giter VIP logo

onerror's Issues

use node 6.7 提示:

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
AssertionError: non-error thrown: [object Object]
at Object.app.context.onerror (/mnt/api/node_modules/koa-onerror/index.js:38:5)
at process._tickDomainCallback (internal/process/next_tick.js:129:7)

How to set up json for response error messages.

code

const onerror = require('koa-onerror')
const app = new Koa()

onerror(app, {
  accepts: 'json',
})

.... occurred an error.

Your code print out this message

(node:25492) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: options.accepts.call is not a function
(node:25492) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

  • How to set up JSON for response error messages when my node program has an error?
  • I think your document add some code and comment for this situation. If you reply to my issue, I will send P.R.
  • I saw this link( https://github.com/koajs/onerror/blob/master/index.js#L38), so what should I do? What do you want to me? please, more tell me some guide

No way to get the original *non-error thrown* message

Notice https://github.com/koajs/onerror/blob/master/index.js#L35

I'm using server slide render with koa, what means Error will be thrown from a bundler file, then the Error instance is not an instance of node Error.

Then what if I just throw {status: 404}, follow the code it will be transformed to non-error thrown: [Object object], so there will be no way to get the original error message!

Should we just delete this line of code or find another way?

How can I customize my own error message

I've just come into contact with koa related technologies, but the instructions in readme seem a little simple. I don't know how to use onerror to customize my own things. Can you explain it

@types/koa-error

If any of the project maintainers have time, can you create a @types/koa-error repository, it would be a great help to ts project, if the maintainers don't have time I can help create it too.

AssertionError: non-error thrown: false

assert.js:98
  throw new assert.AssertionError({
        ^
AssertionError: non-error thrown: false
    at Object.app.context.onerror (/Users/mk2/git/personalweb/node_modules/chair/node_modules/koa-onerror/index.js:50:5)
    at Socket.done (/Users/mk2/git/personalweb/node_modules/chair/node_modules/koa/node_modules/finished/index.js:15:5)
    at Socket.EventEmitter.emit (events.js:126:20)
    at TCP.close (net.js:467:12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.