How to extract the name of a failed service from the error dump?

The last error document has a field called “service”, but this field returns the name of the failed step(e.g: pub.flow:divideInts in case of a divide by 0 error), but I want to retrieve the fully qualified name of the parent flow service, i.e. the service in which this error (say divide by 0) has occurred.

Is there any way by which we can retrieve the name of the failed service from the error dump field that is found inside the last error document ?

Thanks & Regards,
Anwit

There’s no built-in service to return the name of the current service, as far as I know. Instead, you can use Tundra/tundra.service:self, from the open source Tundra package that I maintain, to return the name of the current service (ie. the service that invokes it).

However, if you don’t want to or can’t install the full Tundra package, you can copy/move/rename the extracted service in the attached standalone package ServiceSelf-v0.0.1.zip.

Or, if you want code it yourself, here’s the relevant Java source for your perusal:


// returns the name of the current service, or null if invoked directly
public static String self() {
  String self = null;
  java.util.Stack stack = com.wm.app.b2b.server.InvokeState.getCurrentState().getCallStack();
  if (stack.size() > 1) {
    self = stack.get(stack.size() - 2).toString(); // this will return this service's caller
  }
  return self;
}

ServiceSelf-v0.0.1.zip (10.4 KB)

1 Like

Use getLastError BIS and make use of lastError document you will get the service detail at which it failed.

Thank you Lachlan

this java code may help:
Service.getCallingService().toString();

use this code in a java service to get the fully qualified name.