mathpan/error.go

25 lines
479 B
Go
Raw Normal View History

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