Added error sub package
This commit is contained in:
@@ -2,35 +2,6 @@
|
||||
|
||||
import { inspect } from 'node:util';
|
||||
|
||||
class Not_Storable_Error extends Error {
|
||||
constructor(data) {
|
||||
const { storage, value, property, id } = data;
|
||||
const type = value === null ? 'null' : typeof value;
|
||||
const location = property ? `property "${property}" of record #${id}` : `record #${id}`;
|
||||
super(`Cannot store value of type "${type}" in ${location}: ${inspect(value)}`);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
class Not_Mutable_Error extends Error {
|
||||
constructor(data) {
|
||||
const { storage, value, property, id } = data;
|
||||
const type = value === null ? 'null' : typeof value;
|
||||
const location = property ? `property "${property}" of record #${id}` : `record #${id}`;
|
||||
super(`Cannot set ${location}: record is immutable (tried to store value of type "${type}": ${inspect(value)})`);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
class No_Such_Object_Index_Error extends Error {
|
||||
constructor(data) {
|
||||
const { storage, property, id } = data;
|
||||
const location = property ? `property "${property}" of record #${id}` : `record #${id}`;
|
||||
super(`Cannot get ${location}: no such record index`);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function load_descriptor({ type, value }, { storage, mutable }) {
|
||||
if (type === 'primitive') {
|
||||
|
||||
Reference in New Issue
Block a user