-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ModelError now accepts a previous error
- Loading branch information
1 parent
86d16c0
commit 4052adf
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const assert = require('assert'); | ||
|
||
const ModelError = require('../lib/model-error'); | ||
|
||
describe('Api Session Error', () => { | ||
|
||
it('Should accept a message error and a code', () => { | ||
const error = new ModelError('Some error', ModelError.codes.DATABASE_CONFIG_NOT_FOUND); | ||
|
||
assert.strictEqual(error.message, 'Some error'); | ||
assert.strictEqual(error.code, ModelError.codes.DATABASE_CONFIG_NOT_FOUND); | ||
assert.strictEqual(error.name, 'ModelError'); | ||
}); | ||
|
||
it('Should accept an error instance and a code', () => { | ||
|
||
const previousError = new Error('Some error'); | ||
|
||
const error = new ModelError(previousError, ModelError.codes.DATABASE_CONFIG_NOT_FOUND); | ||
|
||
assert.strictEqual(error.message, 'Some error'); | ||
assert.strictEqual(error.code, ModelError.codes.DATABASE_CONFIG_NOT_FOUND); | ||
assert.strictEqual(error.name, 'ModelError'); | ||
assert.strictEqual(error.previousError, previousError); | ||
}); | ||
}); |