summaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go92
1 files changed, 92 insertions, 0 deletions
diff --git a/errors.go b/errors.go
new file mode 100644
index 0000000..7da8395
--- /dev/null
+++ b/errors.go
@@ -0,0 +1,92 @@
+package prep
+
+// Gemini's excellent at this sorta research. Not much else though
+
+// This file defines a set of conventional exit codes for command-line applications,
+// based on the BSD `sysexits.h` standard and common GNU/Linux practices.
+// Using these constants makes the program's exit behavior clear and consistent.
+
+// ExitCode represents a program's exit status code.
+type ExitCode int
+
+const (
+ // --- Standard Success/Failure ---
+
+ // ExitSuccess indicates that the program completed its task without errors.
+ ExitSuccess ExitCode = 0
+
+ // ExitFailure is a generic, catch-all code for "something went wrong."
+ // It should be used if no other more specific code applies.
+ ExitFailure ExitCode = 1
+
+ // --- Errors based on BSD sysexits.h ---
+
+ // ExitUsage indicates that the user provided invalid command-line arguments or flags.
+ // (Standard: EX_USAGE)
+ ExitUsage ExitCode = 64
+
+ // ExitDataErr indicates that the input data was incorrect or malformed.
+ // (e.g., a corrupt configuration file).
+ // (Standard: EX_DATAERR)
+ ExitDataErr ExitCode = 65
+
+ // ExitNoInput indicates that an input file was not found or could not be read.
+ // (Standard: EX_NOINPUT)
+ ExitNoInput ExitCode = 66
+
+ // ExitNoUser indicates that a specified user did not exist.
+ // (Standard: EX_NOUSER)
+ ExitNoUser ExitCode = 67
+
+ // ExitNoHost indicates that a specified host did not exist.
+ // (Standard: EX_NOHOST)
+ ExitNoHost ExitCode = 68
+
+ // ExitUnavailable indicates that a required service is unavailable.
+ // (Standard: EX_UNAVAILABLE)
+ ExitUnavailable ExitCode = 69
+
+ // ExitSoftware indicates an internal software error. This is for unexpected
+ // conditions and bugs ("this should never happen").
+ // (Standard: EX_SOFTWARE)
+ ExitSoftware ExitCode = 70
+
+ // ExitOSErr indicates an operating system error, such as a failed system call.
+ // (e.g., fork failed, couldn't create a directory).
+ // (Standard: EX_OSERR)
+ ExitOSErr ExitCode = 71
+
+ // ExitOSFile indicates a critical OS file is missing or corrupt.
+ // (e.g., /etc/passwd).
+ // (Standard: EX_OSFILE)
+ ExitOSFile ExitCode = 72
+
+ // ExitCantCreat indicates that a user-specified output file could not be created.
+ // (Standard: EX_CANTCREAT)
+ ExitCantCreat ExitCode = 73
+
+ // ExitIOErr indicates an error occurred during an I/O operation.
+ // (Standard: EX_IOERR)
+ ExitIOErr ExitCode = 74
+
+ // ExitTempFail indicates a temporary failure. The user is invited to retry.
+ // (Standard: EX_TEMPFAIL)
+ ExitTempFail ExitCode = 75
+
+ // ExitProtocol indicates a protocol error during network communication.
+ // (Standard: EX_PROTOCOL)
+ ExitProtocol ExitCode = 76
+
+ // ExitNoPerm indicates that the user does not have sufficient permissions.
+ // This is for filesystem permissions, not for authentication issues.
+ // (Standard: EX_NOPERM)
+ ExitNoPerm ExitCode = 77
+
+ // ExitConfig indicates that something is wrong in a configuration file.
+ // (Standard: EX_CONFIG)
+ ExitConfig ExitCode = 78
+)
+
+// Note: Exit codes 126, 127, and >128 are reserved for the shell to indicate
+// specific execution failures (command not executable, command not found, or
+// termination by a signal) and should not be used by applications.