[haiku-development] Re: Error Handling (was: Re: Plan for NetServices Kit (v2))

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 3 Sep 2021 08:35:21 +0200

Am 03.09.2021 um 00:31 schrieb Ryan Leavengood:

On Thu, Sep 2, 2021 at 12:17 PM Stefano Ceccherini
<stefano.ceccherini@xxxxxxxxx> wrote:
In the end what does really matter is that the api let the application 
developer show a
meaningful message to the user: I hope you don't plan to just throw the stack 
trace to
the user. Unfortunately I've seen many apps do that (mostly java or .net).

For the user yes, but for the developer, stack traces are a lot more helpful than most error messages :-)

But even then, exceptions can (in theory) provide much better error messages than status_t based error handling.
A B_ERROR is not as expressive as a "Unexpected character '<' at column 5". Exceptions make it much easier to transport the actual error.

Good error handling usually gets more complex with status_t. In theory. In real life, exception messages are often worse than they could, and don't really differ that much from a status_t error message. Only the stack trace make them more valuable then (to a developer, at least), but that can be a huge difference, too.

Bye,
   Axel.

Other related posts: