-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy patharithmetic-error.go
More file actions
28 lines (22 loc) · 949 Bytes
/
arithmetic-error.go
File metadata and controls
28 lines (22 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2023, Peter Ohler, All rights reserved.
package slip
import "fmt"
// ArithmeticErrorSymbol is the symbol with a value of "arithmetic-error".
const ArithmeticErrorSymbol = Symbol("arithmetic-error")
// ArithmeticErrorNew creates a ArithmeticError (arithmetic-error) describing
// a arithmetic error.
func ArithmeticErrorNew(s *Scope, depth int, operation Object, operands List, format string, args ...any) Object {
c := FindClass("arithmetic-error")
obj := c.MakeInstance()
obj.Init(s, List{
Symbol(":operation"), operation,
Symbol(":operands"), operands,
Symbol(":message"), String(fmt.Sprintf(format, args...)),
}, depth)
return obj
}
// ArithmeticPanic raises a ArithmeticError (arithmetic-error) describing a
// arithmetic error.
func ArithmeticPanic(s *Scope, depth int, operation Object, operands List, format string, args ...any) {
panic(ArithmeticErrorNew(s, depth, operation, operands, format, args...))
}