Hi all
I'm implementing a custom operation and using chainException framework to capture exception thrown in a chain, based on:
https://doc.nuxeo.com/display/NXDOC/Automation+Chain+Exception
<extension target="org.nuxeo.ecm.core.operation.OperationServiceComponent"
point="chains">
<chain id="**customExceptionReturn**">
<operation id="**Custom.Exception.Create**" />
</chain>
And it works ok. I can select the chain to be thrown when my custom chain fails and I can return a custom exception from this chain. But the webEngine returns a HTTP 200 code when I want it to return a 500.
This is my Exception
public class CustomException extends RestOperationException {}
and how is it used in operation Custom.Exception.Create :
@OperationMethod()
public CustomException run() throws CustomException{
CustomException retVal = null;
Object excName = ctx.get("exceptionName");
Object excObject = ctx.get("exceptionObject");
_log.error("Registering new CustomException: " + excObject);
retVal = (CustomException)excObject;
retVal.setStatus(500);
}
The exception is extracted correctly and I can set the correct message, but it throws a 200 code instead a 500 (as set in my code).
This is the result:
{
"entity-type": "org.custom.nuxeo.operations.exception.CustomException",
"value": {
"className": "org.custom.nuxeo.operations.exception.CustomException",
"status": 500,
"rollback": true,
"cause": null,
"message": "OLEEEE is not a registered core type",
"localizedMessage": "OLEEEE is not a registered core type",
...
And I want this this way:
{
"entity-type": "exception",
"code": "org.nuxeo.ecm.automation.TraceException",
"status": 500,
"stacktrace": "org.nuxeo.ecm.webengine.W
I've take a look at
https://github.com/nuxeo/nuxeo/blob/6.0-HF27/nuxeo-features/rest-api/nuxeo-rest-api-server/src/main/java/org/nuxeo/ecm/restapi/server/jaxrs/adapters/OperationAdapter.java#L94
But I could not get it working.
Any ideas please?
Thanks