Child pages
  • Sample Default Error Handler
Skip to end of metadata
Go to start of metadata

Configuring the Default Error Handler

The example below illustrates a sample default error handler that mails details about a failed flow, and then optionally restarts the failed flow. You can install this flow by doing the following:

  • Download this workflow link into the Flux Installation Directory. 
  • Edit the runtime configuration properties file to point the default error handler to the above file: 
    • Define the location of the default error handler
      /DEFAULT_FLOW_CHART_ERROR_HANDLER
      =Demo_ErrorHandler with Mail Action and Configurable Restart.ffc

    • Set the default restart action to true: 
      /RESTART=true 
    • Save the runtime configuration file.
  • Edit the Mail Action in the error handler workflow using the Flux Designer.
    • Import the flowchart from the file system (i.e., the Flux installation directory) into the Flux Designer
    • Edit the mail action for the mail server, password, etc. Do not use runtime variables in this workflow since this workflow is loaded before any processing starts within Flux.
    • Save back to the file system. 
  • Download this workflow link and import the workflow into your Flux repository. 
  • The Flux engine will start using the default error handler after the runtime configuration refresh frequency has passed.

Testing the Default Error Handler

  • Here is a simple workflow that, when submitted, generates a "divide by zero" exception to force the workflow to fail and trigger the default error handler. If everything is working as expected the default error handler should restart this workflow and send out an email, until the workflow is removed from the Dashboard. 

For reference - here are the two workflows and their underlying scripts.

Demo_ErrorHandler with Mail Action and Configurable Restart.ffc

The Mail Action runs the following prescript to gather failure information and format it into the outbound mail:

String BodyText = "\n";
String SubjectText;
if (flowContext != null) {
FlowChart myChart = flowContext.getFlowChart();
String myChartName = myChart.getName();
String curActionName = flowContext.getActionName();
String throwingActionName = "No error action available";
String message = "No message available.";
String stackTrace = "No stacktrace available";
if (flowContext.getErrorResult() != null) {
throwingActionName = flowContext.getErrorResult().throwingAction;
message = flowContext.getErrorResult().message;
stackTrace = flowContext.getErrorResult().stackTrace;
}
SubjectText = "Flux Error: " + myChartName + " failed";
BodyText = BodyText + "There was an error in flowchart " + myChartName;
BodyText = BodyText + " during action \"" + throwingActionName +"\"" +"\n";
BodyText = BodyText + " The error was \"" + message + "\" \n" + "\n";
BodyText = BodyText + "The stack trace is: \n";
BodyText = BodyText + stackTrace + "\n";
myChart.getAction(curActionName).setBody(BodyText);
myChart.getAction(curActionName).setSubject(SubjectText);

flowContext.put("FAILING_ACTION",throwingActionName);
flowContext.put("FAILURE_MESSAGE",message);
flowContext.put("FAILED_FLOWCHART",myChartName);
} else {
flowContext.put("FAILING_ACTION","Unknown");

Demo_Null Action to Restart a Failed Flowchart.ffc

Runs the script:

// Only run if a valid failed flowchart name is available
if (!"${failed_flowchart}".startsWith("$")) {
Thread.sleep(3000);
Engine engine = flowContext.getEngine();
engine.restart("${failed_flowchart}");
System.out.println("Restarting: " + "${failed_flowchart}");
}


  • No labels