mathpan/error.go

28 lines
546 B
Go
Raw Permalink Normal View History

2022-11-21 05:51:09 +00:00
package main
type Error int
const (
ErrorUnknownOpcode Error = iota
ErrorDivideByZero
ErrorWrongOperandCount
2022-11-21 06:07:46 +00:00
ErrorNegativeShiftAmount
ErrorWrongType
2022-11-21 05:51:09 +00:00
)
func (err Error) Error () (description string) {
switch err {
case ErrorUnknownOpcode:
description = "unknown opcode"
case ErrorDivideByZero:
description = "division by zero"
case ErrorWrongOperandCount:
2022-11-21 06:07:46 +00:00
description = "wrong operand amount"
case ErrorNegativeShiftAmount:
description = "negative shift amount"
case ErrorWrongType:
description = "wrong type"
2022-11-21 05:51:09 +00:00
}
return
}