For the mostpart, Rust error handling is okay. What really rustles my jimmies, however, is the often mandatory indentation because of a lack of an inverse "if let". I prefer to bail out of a block if a condition is NOT met, rather than execute another nested block if it IS met. Rust makes that harder than it should be. It's good code hygiene in every other language, and Rust makes it painful in places. I've even been…
Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
11–20 of 204 posts
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#12For the mostpart, Rust error handling is okay. What really rustles my jimmies, however, is the often mandatory indentation because of a lack of an inverse "if let". I prefer to bail out of a block if a condition is NOT met, rather than execute another nested block if it IS met. Rust makes that harder than it should be. It's good code hygiene in every other language, and Rust makes it painful in places. I've even been…
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#13 - You bubble up errors using `?` operator,
- then you get a nice error message.
- However the location of the error is lost, the more complex the program, the harder it is to figure out where "permission denied" for example comes from.Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#14Assuming they only had access to basic tools they could have just plopped down a breakpoint in the relevant error return from copy_from_process() and slowly walk up to discover their nullptr error pretty quickly without any code changes. If they had modern tools they could have just turned on tracing and then run backwards to figure that out and where the nullptr came from.
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#15Error handling has been wrong since the beginning, and has continued to be wrong ever since. First, we had error codes. Except these were wrong because people forget all the time to check them. Then we had exceptions, which solved the problem of people forgetting to check by crashing the app. Then the Java team got the bright idea to have checked exceptions, which at first helped to mitigate crashes from uncaught exc…
Maybe it's not error-handling that is the problem then, but undisciplined software developers writing bad code?
Out of all the engineering disciplines, us software engineers have to be the worst bunch by far.
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#16As a side note, I've found that getting used to `Result` actually gives an added benefit of getting comfortable with the idea of such computational contexts in general. Be it Options, Maybes, Futures, Promises, Haskell IO, or anything of that kind.
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#17Maybe that day will be a day after _f$#$@@#$_ _crashing_ stops being the easiest and most idiomatic way of handling unexpected conditions.
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#18For the mostpart, Rust error handling is okay. What really rustles my jimmies, however, is the often mandatory indentation because of a lack of an inverse "if let". I prefer to bail out of a block if a condition is NOT met, rather than execute another nested block if it IS met. Rust makes that harder than it should be. It's good code hygiene in every other language, and Rust makes it painful in places. I've even been…
Try methods "is_err", "is_ok"; or for Option: "is_some", "is_none".
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#19Error handling has been wrong since the beginning, and has continued to be wrong ever since. First, we had error codes. Except these were wrong because people forget all the time to check them. Then we had exceptions, which solved the problem of people forgetting to check by crashing the app. Then the Java team got the bright idea to have checked exceptions, which at first helped to mitigate crashes from uncaught exc…
That’s not true.
Re: Where Everything Went Wrong: Error Handling and Error Messages in Rust (2020)
#20Error handling has been wrong since the beginning, and has continued to be wrong ever since. First, we had error codes. Except these were wrong because people forget all the time to check them. Then we had exceptions, which solved the problem of people forgetting to check by crashing the app. Then the Java team got the bright idea to have checked exceptions, which at first helped to mitigate crashes from uncaught exc…
Code contracts are wonderful way of dealing with 1st and 2nd kind, sadly they didn't catch up and remains mostly unknown. They are vastly superior to tests and also serve as much better way to document intent of the code, how the author expected the code to work.