package main type Error int const ( ErrorUnknownOpcode Error = iota ErrorDivideByZero ErrorWrongOperandCount ErrorNegativeShiftAmount ErrorWrongType ) func (err Error) Error () (description string) { switch err { case ErrorUnknownOpcode: description = "unknown opcode" case ErrorDivideByZero: description = "division by zero" case ErrorWrongOperandCount: description = "wrong operand amount" case ErrorNegativeShiftAmount: description = "negative shift amount" case ErrorWrongType: description = "wrong type" } return }