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)
| 632 | /// |
| 633 | /// The exit code to use when terminating due to this error. |
| 634 | pub fn exit_code(&self) -> i32 { |
| 635 | match self { |
| 636 | // User-fixable, general errors |
| 637 | Self::NothingToRecord |
| 638 | | Self::Cancelled |
| 639 | | Self::FileAlreadyTracked { .. } |
| 640 | | Self::RequiresForce { .. } |
| 641 | | Self::ViewAlreadyExists { .. } => 1, |
| 642 | |
| 643 | // Command-line usage errors |
| 644 | Self::InvalidArgument { .. } => 2, |
| 645 | |
| 646 | // Repository/data errors |
| 647 | Self::RepositoryNotFound { .. } |
| 648 | | Self::RepositoryExists { .. } |
| 649 | | Self::InvalidPath { .. } |
| 650 | | Self::InvalidRepository { .. } |
| 651 | | Self::ViewNotFound { .. } |
| 652 | | Self::CannotDeleteCurrentView { .. } |
| 653 | | Self::FileNotFound { .. } |
| 654 | | Self::FileNotTracked { .. } |
| 655 | | Self::PathOutsideRepository { .. } |
| 656 | | Self::PathIgnored { .. } |
| 657 | | Self::ChangeNotFound { .. } |
| 658 | | Self::VaultEntityNotFound { .. } |
| 659 | | Self::AmbiguousHash { .. } |
| 660 | | Self::MissingDependency { .. } |
| 661 | | Self::Conflict { .. } |
| 662 | | Self::ConflictMarkers { .. } |
| 663 | | Self::FileTooLarge { .. } |
| 664 | | Self::IdentityNotFound(_) |
| 665 | | Self::IdentityAlreadyExists(_) => 3, |
| 666 | |
| 667 | // Remote/network errors |
| 668 | Self::RemoteError { .. } |
| 669 | | Self::RemoteNotFound { .. } |
| 670 | | Self::AuthenticationFailed { .. } |
| 671 | | Self::GitError { .. } => 4, |
| 672 | |
| 673 | // IO and config errors |
| 674 | Self::Io(_) | Self::Config(_) => 3, |
| 675 | |
| 676 | // Repository library errors |
| 677 | Self::Repository(_) => 3, |
| 678 | |
| 679 | // Internal errors (bugs) |
| 680 | Self::Internal(_) => 128, |
| 681 | } |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | // Tests |
no outgoing calls