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)
| 567 | /// |
| 568 | /// The exit code to use when terminating due to this error. |
| 569 | pub fn exit_code(&self) -> i32 { |
| 570 | match self { |
| 571 | // User-fixable, general errors |
| 572 | Self::NothingToRecord |
| 573 | | Self::Cancelled |
| 574 | | Self::FileAlreadyTracked { .. } |
| 575 | | Self::RequiresForce { .. } |
| 576 | | Self::ViewAlreadyExists { .. } => 1, |
| 577 | |
| 578 | // Command-line usage errors |
| 579 | Self::InvalidArgument { .. } => 2, |
| 580 | |
| 581 | // Repository/data errors |
| 582 | Self::RepositoryNotFound { .. } |
| 583 | | Self::RepositoryExists { .. } |
| 584 | | Self::InvalidPath { .. } |
| 585 | | Self::InvalidRepository { .. } |
| 586 | | Self::ViewNotFound { .. } |
| 587 | | Self::CannotDeleteCurrentView { .. } |
| 588 | | Self::FileNotFound { .. } |
| 589 | | Self::FileNotTracked { .. } |
| 590 | | Self::PathOutsideRepository { .. } |
| 591 | | Self::PathIgnored { .. } |
| 592 | | Self::ChangeNotFound { .. } |
| 593 | | Self::AmbiguousHash { .. } |
| 594 | | Self::MissingDependency { .. } |
| 595 | | Self::Conflict { .. } |
| 596 | | Self::IdentityNotFound(_) |
| 597 | | Self::IdentityAlreadyExists(_) => 3, |
| 598 | |
| 599 | // Remote/network errors |
| 600 | Self::RemoteError { .. } |
| 601 | | Self::RemoteNotFound { .. } |
| 602 | | Self::AuthenticationFailed { .. } |
| 603 | | Self::GitError { .. } => 4, |
| 604 | |
| 605 | // IO and config errors |
| 606 | Self::Io(_) | Self::Config(_) => 3, |
| 607 | |
| 608 | // Repository library errors |
| 609 | Self::Repository(_) => 3, |
| 610 | |
| 611 | // Internal errors (bugs) |
| 612 | Self::Internal(_) => 128, |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | |
| 617 | // Tests |
no outgoing calls