mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-24 19:44:21 +01:00
refactor(javascript): simplify SqliteError
This commit is contained in:
@@ -1,22 +1,14 @@
|
||||
'use strict';
|
||||
const descriptor = { value: 'SqliteError', writable: true, enumerable: false, configurable: true };
|
||||
|
||||
function SqliteError(message, code, rawCode) {
|
||||
if (new.target !== SqliteError) {
|
||||
return new SqliteError(message, code);
|
||||
}
|
||||
if (typeof code !== 'string') {
|
||||
throw new TypeError('Expected second argument to be a string');
|
||||
}
|
||||
Error.call(this, message);
|
||||
descriptor.value = '' + message;
|
||||
Object.defineProperty(this, 'message', descriptor);
|
||||
Error.captureStackTrace(this, SqliteError);
|
||||
this.code = code;
|
||||
this.rawCode = rawCode
|
||||
class SqliteError extends Error {
|
||||
constructor(message, code, rawCode) {
|
||||
super(message);
|
||||
this.name = 'SqliteError';
|
||||
this.code = code;
|
||||
this.rawCode = rawCode;
|
||||
|
||||
Error.captureStackTrace(this, SqliteError);
|
||||
}
|
||||
}
|
||||
Object.setPrototypeOf(SqliteError, Error);
|
||||
Object.setPrototypeOf(SqliteError.prototype, Error.prototype);
|
||||
Object.defineProperty(SqliteError.prototype, 'name', descriptor);
|
||||
module.exports = SqliteError;
|
||||
|
||||
module.exports = SqliteError;
|
||||
|
||||
Reference in New Issue
Block a user