3 ms·
How would an exception automate the behavior of „?“? What ? does in rust is to unwrap the result check if it is err and return from the function with an error
by larusso 4y ago
How would an exception automate the behavior of „?“?
What ? does in rust is to unwrap the result check if it is err and return from the function with an error result. On top of that it will auto-convert the error type (if the type has the from/into traits implemented)
So it would do:
try {
//the code that may fail
} catch (error) {
//do we just throw the same error?
//or convert the exception to a custom other exception
}
If I see an API that throws me an low level exception without context I go mad. Like an file not found exception etc when executing an API that does multiple file IO operations.