Skip to content

Commit

Permalink
Improve exception logic
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Nov 19, 2024
1 parent a98fbbe commit 64e448f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Module;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.values.BError;

import java.util.concurrent.CompletableFuture;

Expand All @@ -47,6 +48,11 @@ public static Module getModule() {
public static Object getResult(CompletableFuture<Object> balFuture) {
try {
return balFuture.get();
} catch (BError error) {
throw error;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw ErrorCreator.createError(e);
} catch (Throwable throwable) {
throw ErrorCreator.createError(throwable);
}
Expand Down

0 comments on commit 64e448f

Please sign in to comment.