How to force a custom exception in Custom Code

0 votes

Hello. In examples from the custom code we can see this:

return new HttpResponseObject(HTTP_STATUS_SUCCESS, response);
 
This is the natural way to end a Custom Code. However in my case I would like to force an exception of the execution of the custom code if something went wrong, because I don't want to treat different situations in client. In the client I want to have two situations - SUCCESS or EXCEPTION.
 
Otherwise speaking, in my client it always expects a successful response. If something is wrong it expects an exception. But how could I trigger an Custom Code exception. Would that work?
 
return new HttpResponseObject(500, null);
asked Jul 24, 2015 in App42 Cloud API-BaaS by chetruscavladislav (10 points)

1 Answer

0 votes

You can return HttpResponseObject by setting up exception code and message along as shown below 

 

int exceptionCode = 500;

String exceptionMessage = "Something Went Wrong"

return new HttpResponseObject(exceptionCode exceptionMessage );

This will returtn application error code 1904 and http error code as 500, that you can check on your client by looking at exception code and message along.

Let me know if it helps.

Thanks

Ajay

 

 

answered Jul 24, 2015 by ajay123 (899 points)
Thank you very much!
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...