When you develop custom states, include error output variables that can help you troubleshoot problems in the production environment.
// Define output variables
private static final OutputAttribute outErrMsg =
new OutputAttribute("ERR_MSG", "Error Message");
private static final OutputAttribute outErrUUID =
new OutputAttribute("ERR_UUID", "Error Unique ID");
private static final OutputAttribute outSvcCode =
new OutputAttribute("SVC_CODE", "Service Code");
// some code omitted here…
@Override
protected SmappState processStateLogic(…)
{
// Logic implementation
try {
// Reset the error output variable
outErrMsg.setHoldValue("");
outErrUUID.setHoldValue("");
saveOutputAttributes();
return continueOk();
}
catch (Exception ex) {
String uuid = UUID.randomUUID().toString();
log.error(ex.getMessage()+ " [UUID={}]", uuid);
outErrMsg.setHoldValue(message);
outErrUUID.setHoldValue(uuid);
saveOutputAttributes();
return continueFail();
}
}
UUID is a unique user ID that you can use to report errors. For example, if an error occurs, an SMS message can be sent to the consumer, who is identified by the UUID. Consumers can call customer support to report issues, using their UUID. UUIDs are logged so they can be correlated with reported issues.