@worker-tools/deno-kv-storage
Version:
An implementation of the StorageArea (1,2,3) interface for Deno with an extensible system for supporting various database backends.
92 lines • 3.42 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const wasm_js_1 = require("./wasm.js");
const constants_js_1 = require("./constants.js");
class SqliteError extends Error {
/**
* SqliteError
*
* Extension over the standard JS Error object
* to also contain class members for error code
* and error code name.
*
* This class is not exported by the module and
* should only be obtained from exceptions raised
* in this module.
*/
constructor(context, code) {
let message;
let status;
if (typeof context === "string") {
message = context;
status = constants_js_1.Status.Unknown;
}
else {
message = (0, wasm_js_1.getStr)(context, context.get_sqlite_error_str());
status = context.get_status();
}
super(message);
/**
* SqliteError.code
*
* The SQLite result status code,
* see the SQLite docs for more
* information about each code.
*
* https://www.sqlite.org/rescode.html
*
* Beyond the SQLite status codes, this member
* can also contain custom status codes specific
* to this library (starting from 1000).
*
* Errors that originate in the JavaScript part of
* the library will not have an associated status
* code. For these errors, the code will be
* `Status.Unknown`.
*
* | JS name | code | JS name (cont.) | code |
* |------------------|------|------------------|------|
* | SqliteOk | 0 | SqliteEmpty | 16 |
* | SqliteError | 1 | SqliteSchema | 17 |
* | SqliteInternal | 2 | SqliteTooBig | 18 |
* | SqlitePerm | 3 | SqliteConstraint | 19 |
* | SqliteAbort | 4 | SqliteMismatch | 20 |
* | SqliteBusy | 5 | SqliteMisuse | 21 |
* | SqliteLocked | 6 | SqliteNoLFS | 22 |
* | SqliteNoMem | 7 | SqliteAuth | 23 |
* | SqliteReadOnly | 8 | SqliteFormat | 24 |
* | SqliteInterrupt | 9 | SqliteRange | 25 |
* | SqliteIOErr | 10 | SqliteNotADB | 26 |
* | SqliteCorrupt | 11 | SqliteNotice | 27 |
* | SqliteNotFound | 12 | SqliteWarning | 28 |
* | SqliteFull | 13 | SqliteRow | 100 |
* | SqliteCantOpen | 14 | SqliteDone | 101 |
* | SqliteProtocol | 15 | Unknown | -1 |
*
* These codes are accessible via
* the exported `Status` object.
*/
Object.defineProperty(this, "code", {
enumerable: true,
configurable: true,
writable: true,
value: void 0
});
this.code = code !== null && code !== void 0 ? code : status;
this.name = "SqliteError";
}
/**
* SqliteError.codeName
*
* Key of code in exported `status`
* object.
*
* E.g. if `code` is `19`,
* `codeName` would be `SqliteConstraint`.
*/
get codeName() {
return constants_js_1.Status[this.code];
}
}
exports.default = SqliteError;
//# sourceMappingURL=error.js.map
;