Skip to content
  • Dave Collins's avatar
    txscript: Significantly improve errors. · fdc2bc86
    Dave Collins authored
    This converts the majority of script errors from generic errors created
    via errors.New and fmt.Errorf to use a concrete type that implements the
    error interface with an error code and description.
    
    This allows callers to programmatically detect the type of error via
    type assertions and an error code while still allowing the errors to
    provide more context.
    
    For example, instead of just having an error the reads "disabled opcode"
    as would happen prior to these changes when a disabled opcode is
    encountered, the error will now read "attempt to execute disabled opcode
    OP_FOO".
    
    While it was previously possible to programmatically detect many errors
    due to them being exported, they provided no additional context and
    there were also various instances that were just returning errors
    created on the spot which callers could not reliably detect without
    resorting to looking at the actual error message, which is nearly always
    bad practice.
    
    Also, while here, export the MaxStackSize and MaxScriptSize constants
    since they can be useful for consumers of the package and perform some
    minor cleanup of some of the tests.
    fdc2bc86