-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpackage-error.go
More file actions
30 lines (23 loc) · 816 Bytes
/
Copy pathpackage-error.go
File metadata and controls
30 lines (23 loc) · 816 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
29
30
// Copyright (c) 2023, Peter Ohler, All rights reserved.
package slip
import (
"fmt"
)
// PackageErrorSymbol is the symbol with a value of "package-error".
const PackageErrorSymbol = Symbol("package-error")
// PackageErrorNew returns a new PackageError (package-error) describing a
// package error.
func PackageErrorNew(s *Scope, depth int, pkg *Package, format string, args ...any) Object {
c := FindClass("package-error")
obj := c.MakeInstance()
obj.Init(s, List{
Symbol(":package"), pkg,
Symbol(":message"), String(fmt.Sprintf(format, args...)),
}, depth)
return obj
}
// PackagePanic raises a PackageError (package-error) describing a package
// error.
func PackagePanic(s *Scope, depth int, pkg *Package, format string, args ...any) {
panic(PackageErrorNew(s, depth, pkg, format, args...))
}