aboutsummaryrefslogtreecommitdiff
path: root/core/flags/errors.odin
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-06 18:35:43 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-07 13:16:13 -0400
commitedb685f04be9aef407dc8abac7bb76fb51184f9f (patch)
tree63f48c951de7a9d751895a3cd72194e241bd38c0 /core/flags/errors.odin
parent08612423b9afffb7499d8db2c69715df1627bd50 (diff)
Add package `core:flags`
Diffstat (limited to 'core/flags/errors.odin')
-rw-r--r--core/flags/errors.odin58
1 files changed, 58 insertions, 0 deletions
diff --git a/core/flags/errors.odin b/core/flags/errors.odin
new file mode 100644
index 000000000..1862a7a00
--- /dev/null
+++ b/core/flags/errors.odin
@@ -0,0 +1,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 `varg` 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,
+}
+
+Unified_Parse_Error_Reason :: union #shared_nil {
+ Parse_Error_Reason,
+ runtime.Allocator_Error,
+ net.Parse_Endpoint_Error,
+}
+
+// Raised during parsing, naturally.
+Parse_Error :: struct {
+ reason: Unified_Parse_Error_Reason,
+ message: string,
+}
+
+// Raised during parsing.
+// Provides more granular information than what just a string could hold.
+Open_File_Error :: struct {
+ filename: string,
+ errno: os.Errno,
+ mode: int,
+ perms: int,
+}
+
+// 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,
+}