Open mschnell1 opened 2 months ago
The fact is that Error is not very functional right now. I was going to refactor it after I finished the documentation, but that's been put on hold for a number of reasons
@MortalreminderPT
I perfectly get a "File Not Found" error with Workbook::from_path(in_file_name)
I can display it correctly decoded by format!("{:?}", e)
with e
from the result, and hence a WorkbookError.
error: "Io(Os { code: 2, kind: NotFound, message: \"Das System kann die angegebene Datei nicht finden.\" })
I in fact don't understand how the debug print functionality can get that information to be displayed from the private error type.
In the end I would like to just do Workbook::from_path(in_file_name)?;
, but the result type of my function is std::io::Errror
and this is not compiled as no converter function is found.
I implemented it in a new commit, you can see the way to convert a custom Error by clicking here 😊
Sorry, but I still can't find out how to use
the word WorkbookError
( defined in results.rs
) in my code.
That is why I cant compile your snippet.
If I do use edit_xlsx::WorkbookError;
I get no
WorkbookErrorin the root
@MortalreminderPT
Ooops.
Now trying to cargo clean
and recompile I get
--> C:\Users\mschnell\.cargo\registry\src\index.crates.io-6f17d22bba15001f\edit-xlsx-0.4.4\src\result.rs:35:5
|
34 | ColError(ColError),result
| -
| |
| expected one of `(`, `,`, `=`, `{`, or `}`
| help: missing `,`
35 | DuplicatedSheets,
| ^^^^^^^^^^^^^^^^ unexpected token
@MortalreminderPT
Ooops. Now trying to
cargo clean
and recompile I get--> C:\Users\mschnell\.cargo\registry\src\index.crates.io-6f17d22bba15001f\edit-xlsx-0.4.4\src\result.rs:35:5 | 34 | ColError(ColError),result | - | | | expected one of `(`, `,`, `=`, `{`, or `}` | help: missing `,` 35 | DuplicatedSheets, | ^^^^^^^^^^^^^^^^ unexpected token
I may have misunderstood your intention, can you give me more information, like your code snippets, which could help me understand your needs better.
Something seems to have gone wrong with downloading the edit-xlsx code.
I did another clean an compile and now it works. The erroneous word result
is gone now.
Sorry for trouble :(
Nonetheless I can't do (copied from your example)
#[derive(Debug)]
use std::num::ParseIntError;
use edit_xlsx::{Workbook, WorkbookResult, WorkbookError};
enum MyError {
ParseIntError(ParseIntError),
WorkbookError(WorkbookError),
}
I get:
21 | use edit_xlsx::{Workbook, WorkbookResult, WorkbookError};
| ^^^^^^^^^^^^^ no `WorkbookError` in the root
Here a draft of the code I'd like to implement in my project:
let e_text = match e {
edit_xlsx::result::WorkbookError::FileNotFound => "File not Found: ".to_owned() +
&format!("{:?}", in_file_name),
_ => format!("{:?}", e),
};
``
Workbook::from_path(in_file_name)?;
would be an even better option, if a conversion from WorkbookError
into std::io::Error
would be provided.
simply adding pub use result::WorkbookError;
to src/lib.rs
does the trick (temporarily)
It then compiles, but other than hoped, if the file does not exist, the WorkbookError::FileNotFound
is not issued, but WorkbookError::Io
.
Sorry, testing all I can imagine, I can't do what is done in the here
link given above.
As it is in the
results
module, which is private.I simply want to decently print the "file not found error" by