How to customize the Rebellion error message

I used the Restlet framework to provide a RESTful service.

I used ResouceException to return HTTP ERROR CODE like 400 Bad Request, etc.

I have a "new" ResourceException (code, name, desc, uri) with code, name and desc. I am getting the following output:

Bad Request  (name)

period is not a number  (desc)

You can get technical details here.  (uri,though I didn't provide it)

Please continue your visit at our home page.    (home page, I didn't provide, too)

      

I think the last two suggestions are useless for the user to fix the "bad query".

Can I delete them? How to do it? Or If I want to output sth else how to set up the message.

Many thanks.

+3


source to share


1 answer


You can replace the standard one StatusService

with your own.

Extend the class and override getRepresentation(Status, Request, Response)

to provide the format you want.

this can then be set to Application

withsetStatusService(StatusService)



There may be a slightly more modern way of doing this, as the method I'm using has gone through several Restlet updates, but it still works.

Update

as in the case of restarting version 2.3.x the method to override is toRepresentation(Status, Request, Response)

+3


source







All Articles