@bcoders.gr/evm-disassembler
Version:
A comprehensive EVM bytecode disassembler and analyzer with support for multiple EVM versions
54 lines (48 loc) • 1.39 kB
JavaScript
/**
* Custom error classes for EVM bytecode disassembler
* @module errors
*/
/**
* Base error class for bytecode decoder errors
*/
class BytecodeDecoderError extends Error {
constructor(message, code = 'UNKNOWN_ERROR', details = null) {
super(message);
this.name = 'BytecodeDecoderError';
this.code = code;
this.details = details;
}
}
/**
* Error thrown when bytecode is invalid or malformed
*/
class InvalidBytecodeError extends BytecodeDecoderError {
constructor(message, bytecode = null, position = null) {
super(message, 'INVALID_BYTECODE', { bytecode, position });
this.name = 'InvalidBytecodeError';
}
}
/**
* Error thrown when metadata parsing fails
*/
class MetadataParsingError extends BytecodeDecoderError {
constructor(message, metadata = null) {
super(message, 'METADATA_PARSING_ERROR', { metadata });
this.name = 'MetadataParsingError';
}
}
/**
* Error thrown during stack analysis
*/
class StackAnalysisError extends BytecodeDecoderError {
constructor(message, opcode = null, position = null, stackDepth = null) {
super(message, 'STACK_ANALYSIS_ERROR', { opcode, position, stackDepth });
this.name = 'StackAnalysisError';
}
}
module.exports = {
BytecodeDecoderError,
InvalidBytecodeError,
MetadataParsingError,
StackAnalysisError
};