-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: simonsan <[email protected]>
- Loading branch information
Showing
7 changed files
with
102 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use rstest::{fixture, rstest}; | ||
use std::backtrace::Backtrace; | ||
|
||
use rustic_core::{ErrorKind, RusticError, Severity, Status}; | ||
|
||
#[fixture] | ||
fn error() -> RusticError { | ||
RusticError::new( | ||
ErrorKind::Io, | ||
"A file could not be read, make sure the file is existing and readable by the system.", | ||
) | ||
.status(Status::Permanent) | ||
.severity(Severity::Error) | ||
.code("E001".into()) | ||
.add_context("path", "/path/to/file") | ||
.add_context("called", "used s3 backend") | ||
.source(std::io::Error::new(std::io::ErrorKind::Other, "networking error").into()) | ||
.backtrace(Backtrace::disabled()) | ||
} | ||
|
||
#[rstest] | ||
fn test_error_display(error: RusticError) { | ||
insta::assert_snapshot!(error); | ||
} | ||
|
||
#[rstest] | ||
fn test_error_debug(error: RusticError) { | ||
insta::assert_debug_snapshot!(error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
source: crates/core/tests/errors.rs | ||
expression: error | ||
--- | ||
RusticError { | ||
kind: Io, | ||
source: Some( | ||
Custom { | ||
kind: Other, | ||
error: "networking error", | ||
}, | ||
), | ||
guidance: "A file could not be read, make sure the file is existing and readable by the system.", | ||
context: [ | ||
( | ||
"path", | ||
"/path/to/file", | ||
), | ||
( | ||
"called", | ||
"used s3 backend", | ||
), | ||
], | ||
docs_url: None, | ||
code: Some( | ||
"E001", | ||
), | ||
new_issue_url: None, | ||
existing_issue_url: None, | ||
severity: Some( | ||
Error, | ||
), | ||
status: Some( | ||
Permanent, | ||
), | ||
backtrace: Some( | ||
<disabled>, | ||
), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
source: crates/core/tests/errors.rs | ||
expression: TEST_ERROR.to_string() | ||
--- | ||
IO Error occurred in `rustic_core` | ||
|
||
Message: | ||
A file could not be read, make sure the file is existing and readable by the system. | ||
|
||
Context: | ||
path: /path/to/file, | ||
called: used s3 backend | ||
|
||
Caused by: networking error | ||
|
||
Severity: Error | ||
|
||
Status: Permanent | ||
|
||
For more information, see: https://rustic.cli.rs/docs/errors/E001 | ||
|
||
If you think this is an undiscovered bug, please open an issue at: https://github.com/rustic-rs/rustic_core/issues/new | ||
|
||
Backtrace: | ||
<disabled> |