Am 24.02.2014 20:03, schrieb Dicebot:

On Mon, 24 Feb 2014 17:41:54 GMT, Sönke Ludwig wrote:

No, a missing body would mean that a 404 is sent. But I guess we could make an exception and call the error handler with the existing status code for !res.headerWritten && res.satusCode >= 400. Does that sound sane?

Maybe it is better to define extra flag for that and provide a small helper similar to errorOut that both changes status code and sets "error" flag? So that preserving original rendering becomes possible.

The !res.headerWritten already achieves that. As soon as a body is
written, this will become false and thus the error callback isn't
called. The only thing that needs to be distinguished is the 404 case
(because no handler wrote a reply) and a manually set error code that
should trigger the error handler.

But I on pure theory field right now, you'd better ask extrawurst or other guys who actually do projects with vibe.d right here and now :)

Also I wonder what can be done with REST & Co to provide some alternative to exceptions while still preserving the API.

Nothing pretty, I guess. Either you'd have to work with standardized
return codes, or you'd give up the unified interface between the local
implementation and the REST client proxy class (by adding additional
parameters or return values to the proxy class for handling HTTP errors).

Really, I think that exceptions simply have to get fast enough to not be
an issue if they are thrown once per request. They can be a huge help,
especially in a server environment as a safety net and it would be
really sad to abandon them just because of a naive implementation.