AnsweredAssumed Answered

Exception  Handling in java service task

Question asked by prash.aggarwal on Sep 6, 2016
Latest reply on Sep 8, 2016 by jbarrez

I have a java service task  to check the file type validity, i perform this check and want to throw an exception with message like
"Uploaded file type application/pd not supported"

          throw new ABCException("Uploaded file type " + fileType +" not supported");

The stack trace i get is
org.activiti.engine.ActivitiException: Error while evaluating expression: ${uploadService.fileTypeValidityCheck(execution)}

Caused by: org.activiti.engine.impl.javax.el.ELException: com.markit.aft.exception.MIMException: Uploaded file type application/pd not supported

Caused by: Uploaded file type application/pd not supported

How do i show the original message thrown in the exception ie "Uploaded file type " + fileType +" not supported"

Currently I am doing error.setMessage(e.getCause().getCause().getMessage()); as shown below, is this the right way?
Please guide..

    public ResponseEntity<ErrorResponse> handleActivitiException(ActivitiException e){
      ErrorResponse error = new ErrorResponse();
      String errorId = UUID.randomUUID().toString();
      return new ResponseEntity<ErrorResponse>(error, HttpStatus.BAD_REQUEST);