1 | const assert = require('assert');
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | class SipError extends Error {
|
8 |
|
9 | |
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | constructor(...args /*status, reason*/) {
|
18 | super(...args) ;
|
19 |
|
20 | assert.ok(typeof args[0] === 'number', 'first argument to SipError must be number');
|
21 | assert.ok(typeof args[1] === 'string' || typeof args[1] === 'undefined',
|
22 | 'second argument to SipError, if provided, must be a string');
|
23 |
|
24 | this.name = 'SipError' ;
|
25 | this.status = args[0] ;
|
26 | if (args[1]) this.reason = args[1] ;
|
27 | this.message = 'Sip non-success response: ' + this.status ;
|
28 |
|
29 | Error.captureStackTrace(this, SipError);
|
30 | }
|
31 | }
|
32 |
|
33 | module.exports = exports = SipError ;
|