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)
| 607 | /// |
| 608 | /// The exit code to use when terminating due to this error. |
| 609 | pub fn exit_code(&self) -> i32 { |
| 610 | match self { |
| 611 | // User-fixable, general errors |
| 612 | Self::NothingToRecord |
| 613 | | Self::Cancelled |
| 614 | | Self::FileAlreadyTracked { .. } |
| 615 | | Self::RequiresForce { .. } |
| 616 | | Self::ViewAlreadyExists { .. } => 1, |
| 617 | |
| 618 | // Command-line usage errors |
| 619 | Self::InvalidArgument { .. } => 2, |
| 620 | |
| 621 | // Repository/data errors |
| 622 | Self::RepositoryNotFound { .. } |
| 623 | | Self::RepositoryExists { .. } |
| 624 | | Self::InvalidPath { .. } |
| 625 | | Self::InvalidRepository { .. } |
| 626 | | Self::ViewNotFound { .. } |
| 627 | | Self::CannotDeleteCurrentView { .. } |
| 628 | | Self::FileNotFound { .. } |
| 629 | | Self::FileNotTracked { .. } |
| 630 | | Self::PathOutsideRepository { .. } |
| 631 | | Self::PathIgnored { .. } |
| 632 | | Self::ChangeNotFound { .. } |
| 633 | | Self::VaultEntityNotFound { .. } |
| 634 | | Self::AmbiguousHash { .. } |
| 635 | | Self::MissingDependency { .. } |
| 636 | | Self::Conflict { .. } |
| 637 | | Self::ConflictMarkers { .. } |
| 638 | | Self::IdentityNotFound(_) |
| 639 | | Self::IdentityAlreadyExists(_) => 3, |
| 640 | |
| 641 | // Remote/network errors |
| 642 | Self::RemoteError { .. } |
| 643 | | Self::RemoteNotFound { .. } |
| 644 | | Self::AuthenticationFailed { .. } |
| 645 | | Self::GitError { .. } => 4, |
| 646 | |
| 647 | // IO and config errors |
| 648 | Self::Io(_) | Self::Config(_) => 3, |
| 649 | |
| 650 | // Repository library errors |
| 651 | Self::Repository(_) => 3, |
| 652 | |
| 653 | // Internal errors (bugs) |
| 654 | Self::Internal(_) => 128, |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | // Tests |
no outgoing calls