catch server-side errors of a rest server

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

catch server-side errors of a rest server

demarey
Hi,

When you offer a ReST API, you may have errors on the server side.
I wonder how you manage that.
In Zinc-Rest implementation, I did not see a common mechanism to handle Error(s) occurring server side to convert them to HTTP Internal Server Error (500) error code for example.
It looks like a good practice but I would like to know about your practices.
Do you just deactivate the debugger? Do you catch Errors? other?

Thanks,
Christophe.

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: catch server-side errors of a rest server

Sven Van Caekenberghe-2
Did you see Zn[JSON]RestServerDelegate>>#errorResponse:code:message: and follow its users ?

Also, ZnRestServerDelegate>>#handleRequest: does transform any error in a proper REST server error.

Does that help ?

> On 08 Jun 2015, at 16:11, Christophe Demarey <[hidden email]> wrote:
>
> Hi,
>
> When you offer a ReST API, you may have errors on the server side.
> I wonder how you manage that.
> In Zinc-Rest implementation, I did not see a common mechanism to handle Error(s) occurring server side to convert them to HTTP Internal Server Error (500) error code for example.
> It looks like a good practice but I would like to know about your practices.
> Do you just deactivate the debugger? Do you catch Errors? other?
>
> Thanks,
> Christophe.


Reply | Threaded
Open this post in threaded view
|

Re: catch server-side errors of a rest server

demarey

Le 8 juin 2015 à 16:33, Sven Van Caekenberghe a écrit :

Did you see Zn[JSON]RestServerDelegate>>#errorResponse:code:message: and follow its users ?

yes. I saw #serverError:exception: that is using it (and also a bunch of other useful methods)

Also, ZnRestServerDelegate>>#handleRequest: does transform any error in a proper REST server error.

Strangely, I did not catch this one. Surprising because it is one of the two users of #serverError:exception:
It is exactly what I search for.

Does that help ?

Yes, when you put into production, you just need to remove the call to debugMode: true. I forgot this one and then, was surprised to see the debugger popping.

By the way, what is the best strategy to keep a trace of failures. I can see you log failures as announcements. Do you have an object in the image recording all announcements?

Thanks Sven.

smime.p7s (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: catch server-side errors of a rest server

Sven Van Caekenberghe-2

> On 08 Jun 2015, at 16:51, Christophe Demarey <[hidden email]> wrote:
>
>
> Le 8 juin 2015 à 16:33, Sven Van Caekenberghe a écrit :
>
>> Did you see Zn[JSON]RestServerDelegate>>#errorResponse:code:message: and follow its users ?
>
> yes. I saw #serverError:exception: that is using it (and also a bunch of other useful methods)
>
>> Also, ZnRestServerDelegate>>#handleRequest: does transform any error in a proper REST server error.
>
> Strangely, I did not catch this one. Surprising because it is one of the two users of #serverError:exception:
> It is exactly what I search for.

Good.

>> Does that help ?
>
> Yes, when you put into production, you just need to remove the call to debugMode: true. I forgot this one and then, was surprised to see the debugger popping.
>
> By the way, what is the best strategy to keep a trace of failures. I can see you log failures as announcements. Do you have an object in the image recording all announcements?

No, but the beauty of logging as objects is that you can do what you want, just subscribe to

  ZnLogEvent announcer

And filter/do what you want.

> Thanks Sven.


Reply | Threaded
Open this post in threaded view
|

Re: catch server-side errors of a rest server

demarey

Le 8 juin 2015 à 16:59, Sven Van Caekenberghe a écrit :

>
>> On 08 Jun 2015, at 16:51, Christophe Demarey <[hidden email]> wrote:
>>
>> By the way, what is the best strategy to keep a trace of failures. I can see you log failures as announcements. Do you have an object in the image recording all announcements?
>
> No, but the beauty of logging as objects is that you can do what you want, just subscribe to
>
>  ZnLogEvent announcer
>
> And filter/do what you want.
ok, thanks

smime.p7s (5K) Download Attachment