Closed serge012374 closed 11 years ago
It looks like when I try to do something like this in my class:
throw new Exception( 'Custom Exception' ); throw new Exception( 'Custom Exception', -1 );
What I get back is: 500 Internal Server Error
I'd really like to get -1 Custom Exception. Is it possible?
Thank you so much!
Sergey
I'll look in to this.
Ok. It's been a while since I've used my library. It's possible to throw a custom exception using the JsonRPCException()
handler. Use it as a normal Exception()
, and you'll be good to go!
For ex:
if ($i = false) {
throw new JsonRPCException("my custom exception message");
}
But, custom error codes (like your -1) will be set to the 'Internal Server Error' code (-32603).
If you really want to use '-1', you'll have to define it in the jsonRPC2Server.php
file in these 3 arrays: $errorMessages
, $errorMessagesFull
and $errorCodes
.
Please note that as of the Json-rpc 2.0 specification, errorcodes like -1 are not accepted. for custom error codes, you'll have to use an error code between -32000 and -32099. see http://www.jsonrpc.org/specification#error_object for more info.
Hi, Subutux!
Is there a way to generate and use custom error codes?
Thank you!
Sergey