Skip to content

Instantly share code, notes, and snippets.

@MitMaro
Last active February 9, 2018 16:37
Show Gist options
  • Save MitMaro/1b6016902e8eb965c63c738c939b0731 to your computer and use it in GitHub Desktop.
Save MitMaro/1b6016902e8eb965c63c738c939b0731 to your computer and use it in GitHub Desktop.
FeatherJS Express Error Hook Issue

Instructions

npm install
node index

In another terminal:

curl 127.0.0.1:3030/myservice
const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled Rejection');
console.error(reason);
});
const app = express(feathers());
app.configure(express.rest());
app.hooks({
error: () => {
console.log('Throwing error in error hook');
throw new Error('Simulated error');
}
})
app.use('/myservice', {
async find(data, params) {
// trigger error hook
throw new Error();
},
});
app.listen(3030);
console.log('Feathers app started on 127.0.0.1:3030');
{
"name": "feathers-express-error",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@feathersjs/express": "^1.2.0",
"@feathersjs/feathers": "^3.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment