spee.ch/helpers/libraries/errorHandlers.js
Fillerino 085d099040 Edited code to be ES6, added eslint and some basic linting configuration
Edited code to be ES6, added eslint and some basic linting configuration,(also includes husky for auto eslint before push)
2017-06-17 22:51:30 +02:00

22 lines
745 B
JavaScript

module.exports = {
handleRequestError (error, res) {
if (error === 'NO_CLAIMS' || error === 'NO_FREE_PUBLIC_CLAIMS') {
res.status(307).render('noClaims')
} else if (error.response) {
res.status(error.response.status).send(error.response.data.error.message)
} else if (error.code === 'ECONNREFUSED') {
res.status(400).send('Connection refused. The daemon may not be running.')
} else {
res.status(400).send(error.toString())
}
},
handlePublishError (error) {
if (error.code === 'ECONNREFUSED') {
return 'Connection refused. The daemon may not be running.'
} else if (error.response.data.error) {
return error.response.data.error
} else {
return error
}
},
}