fsharp
fsharp copied to clipboard
error-handling: does not show how to deal with errors
TL;DR: I'm missing in this exercise how to handle exceptions thrown (or anay other kind of error bubble) in code called by me and how to properly clean up then.
This exercises shows me how to use failwith
, Option<'T>
and Result<'TOk, 'Terror>
when I want to return it.
It briefly touches how to deal with a Result
that is passed in via the bind
function, but not how to deal with a result returned from another function I've called.
But so far nothing new. We have already returned Option
s and Result
s earlier in the track, so that is nothing new, we did already pattern matching to unwrap our own types, so thats nothing different than the incomming Result
in bind
…
The only thing that is really new, is that we are asked to dispose some object. But wait, what are objects, how to dispose? What oh, I have to call Dispose()
from IDisposable
? Whats that? An interface? Aha… Good luck I have heard of thise things in OOP classes already… So just do it…
In my opinion, this exercise would gain a lot, if we actually had to handle real errors instead of just creating them from nothing.
Eg. in the go
track, we get some kind of resource which we have to open, close, write to, etc, pp. Depending on the current testcase, it will return an error value or raise a panic, and then the student has to react and close the resource handle, or do a retry, or recover from the panic. Here the student has to actually handle errors that were created elsewhere. Thats an example of the exercise I learnt a lot from…
Very good points. This exercise could definitely use an upgrade.
@NobbZ I definitely agree that here we have an exercise that lefts a lot up to the student to be done, and like the approach you went with in the Go track. The C# version could use an overhall as well.
@robkeim please don't get me wrong. I am not a maintainer of the go
track, nor a contributor, I told from the view of a student.
@NobbZ thanks for the clarification, and appreciate you taking the time to write up your feedback. It's very helpful to have feedback from students because as students we're the real customers of Exercism :)
@NobbZ Would you be interested in helping us revamp the error-handling exercise?
Of course I am interested, but I am not really sure how I could help.
@NobbZ Well, perhaps by creating PR or otherwise to help us come up with a better implementation.