Get the exit code that should be used for this error. Different errors have different severity levels, reflected in their exit codes: - 1: General errors (user-fixable issues) - 2: Command-line usage errors - 3: Repository/data errors - 4: Remote/network errors - 128: Internal errors (bugs) # Returns The exit code to use when terminating due to this error.
(&self)
| 590 | /// |
| 591 | /// The exit code to use when terminating due to this error. |
| 592 | pub fn exit_code(&self) -> i32 { |
| 593 | match self { |
| 594 | // User-fixable, general errors |
| 595 | Self::NothingToRecord |
| 596 | | Self::Cancelled |
| 597 | | Self::FileAlreadyTracked { .. } |
| 598 | | Self::RequiresForce { .. } |
| 599 | | Self::ViewAlreadyExists { .. } => 1, |
| 600 | |
| 601 | // Command-line usage errors |
| 602 | Self::InvalidArgument { .. } => 2, |
| 603 | |
| 604 | // Repository/data errors |
| 605 | Self::RepositoryNotFound { .. } |
| 606 | | Self::RepositoryExists { .. } |
| 607 | | Self::InvalidPath { .. } |
| 608 | | Self::InvalidRepository { .. } |
| 609 | | Self::ViewNotFound { .. } |
| 610 | | Self::CannotDeleteCurrentView { .. } |
| 611 | | Self::FileNotFound { .. } |
| 612 | | Self::FileNotTracked { .. } |
| 613 | | Self::PathOutsideRepository { .. } |
| 614 | | Self::PathIgnored { .. } |
| 615 | | Self::ChangeNotFound { .. } |
| 616 | | Self::VaultEntityNotFound { .. } |
| 617 | | Self::AmbiguousHash { .. } |
| 618 | | Self::MissingDependency { .. } |
| 619 | | Self::Conflict { .. } |
| 620 | | Self::IdentityNotFound(_) |
| 621 | | Self::IdentityAlreadyExists(_) => 3, |
| 622 | |
| 623 | // Remote/network errors |
| 624 | Self::RemoteError { .. } |
| 625 | | Self::RemoteNotFound { .. } |
| 626 | | Self::AuthenticationFailed { .. } |
| 627 | | Self::GitError { .. } => 4, |
| 628 | |
| 629 | // IO and config errors |
| 630 | Self::Io(_) | Self::Config(_) => 3, |
| 631 | |
| 632 | // Repository library errors |
| 633 | Self::Repository(_) => 3, |
| 634 | |
| 635 | // Internal errors (bugs) |
| 636 | Self::Internal(_) => 128, |
| 637 | } |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | // Tests |
no outgoing calls