@Gurpreet Singh I just checked the code and the failure simply logs the error message.
case FAIL_RESOLUTION:
session.transfer(session.penalize(putFlowFile), REL_FAILURE);
getLogger().warn("penalizing {} and routing to failure because file with same name already exists",
new Object[]{putFlowFile});
return null;
default:
break;
}
However it is very simply to add this error message as a attribute to the flowfile by creating a attribute called error_message" and assigning the attribute the error message. Then you can routeOnAttribute using the error_message attribute.
flowfile = session.putAttribute(flowfile, "error_message", "penalizing {} and routing to failure because file with same name already exists");