in reply to Re: Prototype "foo {...} bar {...}" is documented?
in thread Prototype "foo {...} bar {...}" is documented?
That's not all Error has to offer though. I use it, so far trying and catching nearly only in tests. I might use try/catch in the future, but so far the implementation of it as an exception object has been pretty useful without the error handling per se.
The reason I like exception objects is that they promote machine recognizable errors, and thus make error handling/reporting easier.
Firstly, each error has a class. You can represent groups of errors rather easily with inheritence.
A certain type of error could inherit from the pseudoclass Error::Recoverable, for example, to allow code catching it to re-attempt the errorneus code. Error categories, for the sake of clean reporting are also nice.
Another feature of error objects is that they are compound. In my errors, the string is just for the user. I have a unique code for each error (generated by a constant allocator). This is more deterministic than matching regexes on error strings.
Now, with all this, and the fact that Error is still outwardly compatible with string errors, since the objects stringify, I see no reason why not to promote at least partial use of the Error module.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Prototype "foo {...} bar {...}" is documented?
by Arunbear (Prior) on Nov 22, 2004 at 12:05 UTC | |
|
Re^3: Prototype "foo {...} bar {...}" is documented?
by TedYoung (Deacon) on Nov 22, 2004 at 14:05 UTC | |
by nothingmuch (Priest) on Nov 22, 2004 at 16:27 UTC | |
by ihb (Deacon) on Nov 24, 2004 at 01:42 UTC | |
by nothingmuch (Priest) on Nov 24, 2004 at 06:54 UTC |