restle-error
Advanced tools
Comparing version 0.0.1 to 0.0.2
33
index.js
@@ -11,14 +11,13 @@ const RestleError = require('./restle-error'); | ||
this.name = `AdapterError`; | ||
this.title = `Adapter failed to connect` | ||
this.title = `Adapter failed to connect`; | ||
this.detail = `The ${type} adapter failed to properly connect. Reason: ${reason}`; | ||
} | ||
NotFoundError = function(options) { | ||
const type = options.type; | ||
const id = options.id; | ||
BadRequestError = function(options) { | ||
const detail = options.detail; | ||
this.status = 404; | ||
this.name = 'NotFoundError'; | ||
this.title = `Resource not found`, | ||
this.detail = `A resource with type '${type}' and id '${id}' was not found.`; | ||
this.status = 400; | ||
this.name = 'BadRequestError'; | ||
this.title = 'Bad request'; | ||
this.detail = detail; | ||
} | ||
@@ -32,14 +31,26 @@ | ||
this.name = `ConflictError`; | ||
this.title = `Conflicting values`, | ||
this.title = `Conflicting values`; | ||
this.detail = `Tried to perform an operation on mismatched types: ${first} and ${second}`; | ||
} | ||
NotFoundError = function(options) { | ||
const type = options.type; | ||
const id = options.id; | ||
this.status = 404; | ||
this.name = 'NotFoundError'; | ||
this.title = `Resource not found`; | ||
this.detail = `A resource with type '${type}' and id '${id}' was not found.`; | ||
} | ||
util.inherits(AdapterError, RestleError); | ||
util.inherits(BadRequestError, RestleError); | ||
util.inherits(ConflictError, RestleError); | ||
util.inherits(NotFoundError, RestleError); | ||
util.inherits(ConflictError, RestleError); | ||
module.exports = { | ||
AdapterError: AdapterError, | ||
BadRequestError: AdapterError, | ||
ConflictError: ConflictError, | ||
NotFoundError: NotFoundError, | ||
ConflictError: ConflictError, | ||
} |
{ | ||
"name": "restle-error", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Restle errors.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
6498
140