aboutsummaryrefslogtreecommitdiff
path: root/core/flags/errors.odin
blob: efe4cb6c4faf56f199a3a7b0e80a37467cfb20f4 (plain)
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
package flags

import "base:runtime"
import "core:net"
import "core:os"

Parse_Error_Reason :: enum {
	None,
	// An extra positional argument was given, and there is no `overflow` field.
	Extra_Positional,
	// The underlying type does not support the string value it is being set to.
	Bad_Value,
	// No flag was given by the user.
	No_Flag,
	// No value was given by the user.
	No_Value,
	// The flag on the struct is missing.
	Missing_Flag,
	// The type itself isn't supported.
	Unsupported_Type,
}

// Raised during parsing, naturally.
Parse_Error :: struct {
	reason: Unified_Parse_Error_Reason,
	message: string,
}

Unified_Parse_Error_Reason :: union #shared_nil {
	Parse_Error_Reason,
	runtime.Allocator_Error,
	net.Parse_Endpoint_Error,
}

// Raised during parsing.
// Provides more granular information than what just a string could hold.
Open_File_Error :: struct {
	filename: string,
	errno: os.Error,
	flags: os.File_Flags,
	perms: os.Permissions,
}

// Raised during parsing.
Help_Request :: distinct bool


// Raised after parsing, during validation.
Validation_Error :: struct {
	message: string,
}

Error :: union {
	Parse_Error,
	Open_File_Error,
	Help_Request,
	Validation_Error,
}