Hi Chris,

There is indeed a limitation in this area. Here is the change that I've just
applied to SVN:

 - Handler.handle() now set the response status to 404 (Not Found) only if
the target
   resource is null *and* if the response status is a success.

Now you can directly update the response status in findTarget() without
having it overwritten by Handler.handle. Let me know if that solves your
issue.

Best regards,
Jerome  

> -----Message d'origine-----
> De : news [mailto:[EMAIL PROTECTED] De la part de Chris Battey
> Envoyé : mercredi 3 janvier 2007 02:04
> À : [email protected]
> Objet : Returning error codes other than 404 from Handler::handle
> 
> At present, it appears that 404 is the only error code that 
> can be returned from
> Handler::handle().  Either a non-null Resource is returned 
> from findTarget() and
> returned correctly, or the return value is null and the 
> result is a 404.
> 
> I want to return different error codes from within findTarget(), more
> specifically 400 and potentially 401, depending on the input. 
>  Originally the
> plan was to do this by creating a child class where the 
> entire body of handle()
> is wrapped in a try/catch block and throwing exceptions up 
> past the place where
> null results get converted into 404 errors, to be caught and 
> converted to error
> codes as needed.  However, that requires creating a new 
> method to replace
> findTarget so it can have a throws statement in its 
> signature, and is also
> extremely brittle to change (as the differences in the 
> Handler between b20 and
> b23 show).
> 
> Is there a better way to have more control over what error 
> codes individual
> restlets can return?

Reply via email to