| 2 | const descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true }; |
| 3 | |
| 4 | function SqliteError(message, code) { |
| 5 | if (new.target !== SqliteError) { |
| 6 | return new SqliteError(message, code); |
| 7 | } |
| 8 | if (typeof code !== 'string') { |
| 9 | throw new TypeError('Expected second argument to be a string'); |
| 10 | } |
| 11 | Error.call(this, message); |
| 12 | descriptor.value = '' + message; |
| 13 | Object.defineProperty(this, 'message', descriptor); |
| 14 | Error.captureStackTrace(this, SqliteError); |
| 15 | this.code = code; |
| 16 | } |
| 17 | Object.setPrototypeOf(SqliteError, Error); |
| 18 | Object.setPrototypeOf(SqliteError.prototype, Error.prototype); |
| 19 | Object.defineProperty(SqliteError.prototype, 'name', descriptor); |