-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ricardo Gama
committed
Dec 5, 2016
1 parent
d287f8b
commit 2990601
Showing
5 changed files
with
37 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import InvalidHeaderError from './invalid-header-error'; | ||
import format from './format'; | ||
import parse from './parse'; | ||
|
||
export {format, parse}; | ||
export {InvalidHeaderError, format, parse}; |
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,10 @@ | ||
const InvalidHeaderError = function InvalidHeaderError(message) { | ||
this.name = 'InvalidHeaderError'; | ||
this.message = message; | ||
this.stack = (new Error()).stack; | ||
}; | ||
|
||
InvalidHeaderError.prototype = Object.create(TypeError.prototype); | ||
InvalidHeaderError.prototype.constructor = InvalidHeaderError; | ||
|
||
export default InvalidHeaderError; |
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,16 @@ | ||
import {expect} from 'chai'; | ||
import InvalidHeaderError from '../../src/invalid-header-error'; | ||
|
||
describe('InvalidHeaderError', () => { | ||
it('should inherit from TypeError', () => { | ||
expect(new InvalidHeaderError()).to.be.an.instanceof(TypeError); | ||
}); | ||
|
||
it('should set given message', () => { | ||
expect(new InvalidHeaderError('foobar').message).to.equal('foobar'); | ||
}); | ||
|
||
it('should set a stack trace', () => { | ||
expect(new InvalidHeaderError().stack).to.not.be.undefined; | ||
}); | ||
}); |
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