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