.cargo/
crates/
brain/
diff/
benches/
src/
bin/
rustik-diff/
error.rs
1.4 KiB
session.rs
13.2 KiB
rustik-diff.rs
4.7 KiB
themes/
viewer/
builtins.rs
13.4 KiB
commit.rs
7.0 KiB
context.rs
10.1 KiB
decode.rs
32.8 KiB
decorate.rs
4.2 KiB
document.rs
25.0 KiB
encode.rs
4.9 KiB
highlight.rs
24.4 KiB
highlighter.rs
12.4 KiB
lib.rs
2.0 KiB
status.rs
2.0 KiB
viewer.rs
191.2 KiB
word.rs
16.8 KiB
tests/
Cargo.toml
867 B
README.md
696 B
files/
highlight/
repo/
signals/
tui/
tui-core/
tui-termion/
tui-widgets/
scripts/
src/
.gitignore
30 B
.gitsigners
198 B
AGENTS.md
1.9 KiB
CONTRIBUTING
1.7 KiB
Cargo.lock
5.4 KiB
Cargo.toml
1.9 KiB
LICENSE
1.1 KiB
README.md
245 B
STYLE
3.7 KiB
clippy.toml
213 B
crates/diff/src/bin/rustik-diff/error.rs
raw
| 1 | //! Error handling for the pager binary. |
| 2 | |
| 3 | use std::io; |
| 4 | |
| 5 | use rustik_diff::DecodeError; |
| 6 | use rustik_highlight as syntax; |
| 7 | use rustik_repo::RepoError; |
| 8 | |
| 9 | /// Binary error type. |
| 10 | #[derive(Debug)] |
| 11 | pub(super) enum Error { |
| 12 | /// I/O failed. |
| 13 | Io(io::Error), |
| 14 | /// Git returned a failing exit status. |
| 15 | Git(i32), |
| 16 | /// Repository discovery or Git plumbing failed. |
| 17 | Repo(RepoError), |
| 18 | /// Diff parsing failed. |
| 19 | Parse(DecodeError), |
| 20 | /// Syntax highlighting setup failed. |
| 21 | Highlight(syntax::Error), |
| 22 | } |
| 23 | |
| 24 | impl From<io::Error> for Error { |
| 25 | fn from(error: io::Error) -> Self { |
| 26 | Self::Io(error) |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | impl From<DecodeError> for Error { |
| 31 | fn from(error: DecodeError) -> Self { |
| 32 | Self::Parse(error) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl From<syntax::Error> for Error { |
| 37 | fn from(error: syntax::Error) -> Self { |
| 38 | Self::Highlight(error) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | impl From<RepoError> for Error { |
| 43 | fn from(error: RepoError) -> Self { |
| 44 | Self::Repo(error) |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | impl std::fmt::Display for Error { |
| 49 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 50 | match self { |
| 51 | Self::Io(error) => write!(f, "{error}"), |
| 52 | Self::Git(code) => write!(f, "git diff exited with status {code}"), |
| 53 | Self::Repo(error) => write!(f, "{error}"), |
| 54 | Self::Parse(error) => write!(f, "{error}"), |
| 55 | Self::Highlight(error) => write!(f, "{error}"), |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | impl std::error::Error for Error {} |