Skip to content

Commit

Permalink
Nice error message on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Jul 27, 2020
1 parent a3ee516 commit adbc82c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions git-odb/src/loose/db/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ quick_error! {
source(err)
}
IoRaw(err: io::Error) {
display("An IO error occurred while writing an object")
source(err)
from()
}
Expand Down
2 changes: 2 additions & 0 deletions git-odb/src/pack/index/traverse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ quick_error! {
#[derive(Debug)]
pub enum Error {
Processor(err: Box<dyn std::error::Error + Send + Sync>) {
display("One of the traversal processors failed")
source(&**err)
from()
}
Expand All @@ -25,6 +26,7 @@ quick_error! {
from()
}
Graph(err: pack::graph::Error) {
display("The pack delta graph could not be built")
from()
source(err)
}
Expand Down
6 changes: 4 additions & 2 deletions gitoxide-core/src/pack/explode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ quick_error! {
#[derive(Debug)]
enum Error {
Io(err: std::io::Error) {
display("An IO error occurred while writing an object")
source(err)
from()
}
Odb(err: loose::db::write::Error) {
OdbWrite(err: loose::db::write::Error) {
display("An object could not be written to the database")
source(err)
from()
}
Expand Down Expand Up @@ -155,7 +157,7 @@ where
}
},
pack::cache::DecodeEntryLRU::default,
).map(|(_,_,c)|progress::DoOrDiscard::from(c)).with_context(|| "Some loose objects could not be extracted")?;
).map(|(_,_,c)|progress::DoOrDiscard::from(c)).with_context(|| "Failed to explode the entire pack - some loose objects may have been created nonetheless")?;

let (index_path, data_path) = (bundle.index.path().to_owned(), bundle.pack.path().to_owned());
drop(bundle);
Expand Down
2 changes: 1 addition & 1 deletion src/plumbing/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mod options {
#[structopt(long)]
delete_pack: bool,

/// The amount of checks to run. Defaults to 'all'.
/// The amount of checks to run
#[structopt(
long,
short = "c",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Error: Failed to explode the entire pack - some loose objects may have been created nonetheless

Caused by:
0: One of the traversal processors failed
1: Failed to write commit object 501b297447a8255d3533c6858bb692575cdefaa0
2: An object could not be written to the database
3: Could not create named temp file in 'does-not-exist'
4: No such file or directory (os error 2) at path "/Users/byron/dev/grit-rs/does-not-exist/.tmpAiSVb8"
10 changes: 5 additions & 5 deletions tests/stateless-journey.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ title "CLI ${kind}"

(when "running 'plumbing pack-explode"
PACK_FILE="$fixtures/packs/pack-11fdfa9e156ab73caae3b6da867192221f2089c2"
(with "no directory specified"
(with "no objects directory specified"
it "explodes the pack successfully and with desired output" && {
WITH_SNAPSHOT="$snapshot/plumbing-pack-explode-to-sink-success" \
expect_run $SUCCESSFULLY "$exe_plumbing" pack-explode "${PACK_FILE}.idx"
Expand All @@ -62,14 +62,14 @@ title "CLI ${kind}"
expect_run $WITH_FAILURE ls ${PACK_FILE}.idx
}
)
(with "TODO(how to write into the middle of a file in bash): an invalid pack"

)
)
)
)
(with "a non-existing directory specified"

it "fails with a helpful error message" && {
WITH_SNAPSHOT="$snapshot/plumbing-pack-explode-missing-objects-dir-fail" \
expect_run $WITH_FAILURE "$exe_plumbing" pack-explode "${PACK_FILE}.idx" does-not-exist
}
)
(with "an existing directory specified"

Expand Down

0 comments on commit adbc82c

Please sign in to comment.