Merge development
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/* eslint-disable max-classes-per-file */
|
||||
|
||||
/**
|
||||
* Error thrown when a required variable is missing.
|
||||
*/
|
||||
export class CashAssemblyRequiredVariableMissingError extends Error {
|
||||
constructor(variableNames?: string[]) {
|
||||
const defaultMessage = 'Missing required variable';
|
||||
if (variableNames !== undefined && variableNames.length > 0) {
|
||||
super(`${defaultMessage}: variableNames [${variableNames.join(', ')}]`);
|
||||
} else {
|
||||
super(defaultMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when cash assembly compilation fails.
|
||||
*/
|
||||
export class CashAssemblyCompilationFailedError extends Error {
|
||||
constructor(message?: string) {
|
||||
const defaultMessage = 'Cash assembly compilation failed';
|
||||
super(message ? `${defaultMessage}: ${message}` : defaultMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a variable's runtime type does not match the type required for compilation.
|
||||
*/
|
||||
export class CashAssemblyVariableTypeMismatchError extends Error {
|
||||
constructor(variableKey: string, expectedType: string, actualType: string) {
|
||||
const defaultMessage = 'Variable type mismatch';
|
||||
super(`${defaultMessage}: variableKey "${variableKey}", expected ${expectedType}, got ${actualType}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a supported primitive hint does not expose the requested method.
|
||||
*/
|
||||
export class CashAssemblyPrimitiveMethodMissingError extends Error {
|
||||
constructor(identifier: string, methodName: string, hint: string) {
|
||||
const defaultMessage = 'CashAssembly primitive method does not exist';
|
||||
super(`${defaultMessage}: identifier "${identifier}", methodName "${methodName}", hint "${hint}"`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a value cannot be resolved as bytes.
|
||||
*/
|
||||
export class CashAssemblyUnsupportedValueTypeError extends Error {
|
||||
constructor(identifier: string, returnedType: string) {
|
||||
const defaultMessage = 'CashAssembly value type is unsupported for byte resolution';
|
||||
super(`${defaultMessage}: identifier "${identifier}", returnedType "${returnedType}"`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a number cannot be safely encoded as a CashAssembly VM number.
|
||||
*/
|
||||
export class CashAssemblyNumberNotSafeIntegerError extends Error {
|
||||
constructor(identifier: string, value: number) {
|
||||
const defaultMessage = 'CashAssembly number is not a safe integer';
|
||||
super(`${defaultMessage}: identifier "${identifier}", got ${String(value)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when a supported primitive is selected but its value is missing when provided in the variables map.
|
||||
*/
|
||||
export class CashAssemblyPrimitiveVariableMissingError extends Error {
|
||||
constructor(identifier: string, variableName: string) {
|
||||
const defaultMessage = 'CashAssembly primitive variable is missing from the variables map';
|
||||
super(`${defaultMessage}: identifier "${identifier}", variableName "${variableName}"`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error thrown when compiled evaluation bytes cannot be decoded as a VM number.
|
||||
*/
|
||||
export class CashAssemblyVmNumberDecodeError extends Error {
|
||||
constructor(reason: string) {
|
||||
const defaultMessage = 'CashAssembly evaluation could not be decoded as a VM number';
|
||||
super(`${defaultMessage}: ${reason}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user