Class SdkCall

java.lang.Object
co.ankatech.ankasecure.sdk.internal.util.SdkCall

public final class SdkCall extends Object
Utility wrapper that executes a lambda calling the OpenAPI client and uniformly maps any ApiException (or runtime failure) to AnkaSecureSdkException via ExceptionTranslator.
 return SdkCall.of("bundle.key", ctx,
                   () -> openApi.doSomething(req),
                   arg0, arg1);
 
  • Method Details

    • of

      public static <R> R of(String bundleKey, Map<String,String> ctx, Callable<R> task, Object... args)
      Executes a given task encapsulated as a Callable, handling exceptions uniformly by translating them into an AnkaSecureSdkException with optional localization.
      Type Parameters:
      R - the type of the result produced by the callable task
      Parameters:
      bundleKey - the key to a localized message in the resource bundle for exception translation
      ctx - a map containing additional context to include in case of an exception
      task - the Callable task to execute
      args - optional arguments for formatting the localized message
      Returns:
      the result produced by executing the provided task
      Throws:
      AnkaSecureSdkException - if the task execution fails, wrapping the original exception