# Exit codes and errors

Source: https://libtmux.org/en/csharp/latest/workspace/reference/exit-codes/

> Use process status and structured error codes to handle workspace failures.

Check the process status before treating a result as complete. A failed load
can report retained effects; a later failure does not undo an earlier input.

| Exit status | Meaning |
| --- | --- |
| `0` | Command completed; an explicitly declined prompt can also finish without changes |
| `1` | Workspace validation or operation failure |
| `2` | Invalid arguments or execution context |
| `130` | Interrupted operation |

Child commands such as `edit` can propagate another nonzero child status.
Status `70` reports an internal error.

## Machine errors

With `--json` or `--ndjson`, diagnostics identify a `code` and readable
`message`. Use the code for program decisions and keep the message for users.

| Code | Condition |
| --- | --- |
| `workspace_not_found` | Requested workspace was not found |
| `invalid_workspace` | Document shape or value is invalid |
| `unsupported_key` | An execution field is unsupported |
| `session_not_found` | The selected session does not exist |
| `session_mismatch` | Existing session does not match the requested document |
| `tmux_unavailable` | tmux cannot be found or used |
| `tmux_failed` | A tmux operation failed |
| `script_failed` | A bootstrap process failed |
| `destination_exists` | A file would be replaced without authorization |
| `usage` | Arguments or execution context are invalid |
| `interrupted` | A signal stopped the operation |

Additional codes describe implementation failures such as a closed output
stream, unavailable runtime or log-file failure. Keep unknown codes visible
instead of assuming they mean success. See [troubleshooting](https://libtmux.org/en/csharp/latest/workspace/guides/troubleshooting/)
for collecting a useful report.

[CLI source](https://github.com/libtmux/libtmux-dotnet/blob/f77fe776ba67a04abb20ddbbc26cf4a000d63b74/src/LibTmux.Workspace.Cli/README.md).
