-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patherrors.v
More file actions
109 lines (98 loc) · 2.61 KB
/
Copy patherrors.v
File metadata and controls
109 lines (98 loc) · 2.61 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module vxui
// =============================================================================
// Error Types - Structured Error Handling
// =============================================================================
// VxuiError represents error codes
pub enum VxuiError {
unknown
client_not_found
no_clients
no_valid_connection
js_timeout
js_validation_failed
js_result_too_large
auth_failed
auth_invalid_token
port_not_available
browser_not_found
file_not_found
path_traversal
route_not_found
// Additional error codes for unified error handling
profile_create_failed
process_fork_failed
hidden_file_access
null_byte_detected
absolute_path_not_allowed
invalid_method
attribute_parse_error
}
// VxuiErrorDetail represents a structured error with code and details
pub struct VxuiErrorDetail {
pub:
code VxuiError
message string
details map[string]string
cause ?IError // Underlying error that caused this error
}
// msg returns the error message (implements IError interface)
pub fn (e VxuiErrorDetail) msg() string {
mut result := e.message
if cause := e.cause {
result += ': ${cause.msg()}'
}
return result
}
// code returns the error code (implements IError interface)
pub fn (e VxuiErrorDetail) code() int {
return int(e.code)
}
// str returns the error message
pub fn (e VxuiErrorDetail) str() string {
return e.msg()
}
// with_cause creates a new error with an underlying cause
pub fn (e VxuiErrorDetail) with_cause(cause IError) VxuiErrorDetail {
return VxuiErrorDetail{
code: e.code
message: e.message
details: e.details
cause: cause
}
}
// with_detail adds a detail to the error
pub fn (e VxuiErrorDetail) with_detail(key string, value string) VxuiErrorDetail {
mut new_details := e.details.clone()
new_details[key] = value
return VxuiErrorDetail{
code: e.code
message: e.message
details: new_details
cause: e.cause
}
}
// new_error_detail creates a new VxuiErrorDetail
pub fn new_error_detail(code VxuiError, message string) VxuiErrorDetail {
return VxuiErrorDetail{
code: code
message: message
details: {}
}
}
// new_error_detail_with_details creates a new VxuiErrorDetail with details
pub fn new_error_detail_with_details(code VxuiError, message string, details map[string]string) VxuiErrorDetail {
return VxuiErrorDetail{
code: code
message: message
details: details
}
}
// new_error_detail_with_cause creates a new VxuiErrorDetail with an underlying cause
pub fn new_error_detail_with_cause(code VxuiError, message string, cause IError) VxuiErrorDetail {
return VxuiErrorDetail{
code: code
message: message
details: {}
cause: cause
}
}