fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

error-handling: does not show how to deal with errors

Open NobbZ opened this issue 6 years ago • 7 comments

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 Options and Results 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…

NobbZ avatar Oct 16 '17 22:10 NobbZ

Very good points. This exercise could definitely use an upgrade.

ErikSchierboom avatar Oct 17 '17 08:10 ErikSchierboom

@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 avatar Oct 17 '17 15:10 robkeim

@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 avatar Oct 17 '17 18:10 NobbZ

@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 :)

robkeim avatar Oct 18 '17 14:10 robkeim

@NobbZ Would you be interested in helping us revamp the error-handling exercise?

ErikSchierboom avatar Feb 12 '18 10:02 ErikSchierboom

Of course I am interested, but I am not really sure how I could help.

NobbZ avatar Feb 16 '18 21:02 NobbZ

@NobbZ Well, perhaps by creating PR or otherwise to help us come up with a better implementation.

ErikSchierboom avatar Feb 17 '18 07:02 ErikSchierboom