Use RestException to throw the exception and use the details parameter (an array) to add additional details
throw new RestException(400, 'invalid user', array('error_code' => 12002));
gives me the following
{
"error": {
"code": 400,
"message": "Bad Request: invalid user",
"error_code": 12002
},
"debug": {
"source": "Say.php:5 at call stage",
"stages": {
"success": [
"get",
"route",
"negotiate",
"validate"
],
"failure": [
"call",
"message"
]
}
}
}
Info:- additional debug information is returned when restler is running in debug mode.
It can be turned off by using Compose::$includeDebugInfo=false;
Note:- Make sure you are using Restler 3.0 RC4 or higher