Repository navigation
Expand file tree
/
Copy patherrors.go
More file actions
75 lines (61 loc) · 1.98 KB
/
Copy patherrors.go
File metadata and controls
75 lines (61 loc) · 1.98 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package e2b
import "fmt"
// Error represents an error returned by the E2B API or SDK.
type Error struct {
// StatusCode is the HTTP status code, if applicable.
StatusCode int
// Message describes what went wrong.
Message string
}
// Error implements the error interface.
func (e *Error) Error() string {
if e.StatusCode != 0 {
return fmt.Sprintf("e2b: status %d: %s", e.StatusCode, e.Message)
}
return fmt.Sprintf("e2b: %s", e.Message)
}
// SandboxNotFoundError is returned when a sandbox cannot be found.
type SandboxNotFoundError struct {
SandboxID string
}
// Error implements the error interface.
func (e *SandboxNotFoundError) Error() string {
return fmt.Sprintf("e2b: sandbox not found: %s", e.SandboxID)
}
// TimeoutError is returned when an operation exceeds its deadline.
type TimeoutError struct {
Message string
}
// Error implements the error interface.
func (e *TimeoutError) Error() string {
return fmt.Sprintf("e2b: timeout: %s", e.Message)
}
// FileNotFoundError is returned when the requested path does not exist in the sandbox.
type FileNotFoundError struct {
Path string
}
// Error implements the error interface.
func (e *FileNotFoundError) Error() string {
return fmt.Sprintf("e2b: file not found: %s", e.Path)
}
// TemplateNotFoundError is returned when a template cannot be found.
type TemplateNotFoundError struct {
TemplateID string
}
// Error implements the error interface.
func (e *TemplateNotFoundError) Error() string {
return fmt.Sprintf("e2b: template not found: %s", e.TemplateID)
}
// TemplateBuildError is returned when a template build finishes with "error" status.
type TemplateBuildError struct {
TemplateID string
BuildID string
Reason BuildStatusReason
}
// Error implements the error interface.
func (e *TemplateBuildError) Error() string {
if e.Reason.Step != "" {
return fmt.Sprintf("e2b: template build failed: %s (step: %s)", e.Reason.Message, e.Reason.Step)
}
return fmt.Sprintf("e2b: template build failed: %s", e.Reason.Message)
}