summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2024-03-05 01:31:43 +0100
committerFlorian Dold <florian@dold.me>2024-03-05 01:31:43 +0100
commit1624c8fd0b2907b41e570dc8b7889354c07a19c8 (patch)
tree1919b885496e2f6540995135f9f08e20ed6a2b71
parent78f93e66ff434fe52baab77155056137c80f30c6 (diff)
downloadwallet-core-1624c8fd0b2907b41e570dc8b7889354c07a19c8.tar.gz
wallet-core-1624c8fd0b2907b41e570dc8b7889354c07a19c8.tar.bz2
wallet-core-1624c8fd0b2907b41e570dc8b7889354c07a19c8.zip
-simplify
-rw-r--r--packages/taler-wallet-core/src/shepherd.ts50
1 files changed, 9 insertions, 41 deletions
diff --git a/packages/taler-wallet-core/src/shepherd.ts b/packages/taler-wallet-core/src/shepherd.ts
index 90cb53aac..a54049d7c 100644
--- a/packages/taler-wallet-core/src/shepherd.ts
+++ b/packages/taler-wallet-core/src/shepherd.ts
@@ -28,7 +28,6 @@ import {
ObservabilityContext,
ObservabilityEventType,
RetryLoopOpts,
- TalerErrorCode,
TalerErrorDetail,
TaskThrottler,
TransactionIdStr,
@@ -38,7 +37,6 @@ import {
assertUnreachable,
getErrorDetailFromException,
j2s,
- makeErrorDetail,
} from "@gnu-taler/taler-util";
import { processBackupForProvider } from "./backup/index.js";
import {
@@ -51,7 +49,6 @@ import {
getExchangeState,
parseTaskIdentifier,
} from "./common.js";
-import { CryptoApiStoppedError } from "./crypto/workers/crypto-dispatcher.js";
import {
OPERATION_STATUS_ACTIVE_FIRST,
OPERATION_STATUS_ACTIVE_LAST,
@@ -343,14 +340,15 @@ export class TaskSchedulerImpl implements TaskScheduler {
);
const startTime = AbsoluteTime.now();
logger.trace(`Shepherd for ${taskId} will call handler`);
- const res = await runTaskWithErrorReporting(
- this.ws,
- taskId,
- info,
- async () => {
- return await callOperationHandlerForTaskId(wex, taskId);
- },
- );
+ let res: TaskRunResult;
+ try {
+ res = await callOperationHandlerForTaskId(wex, taskId);
+ } catch (e) {
+ res = {
+ type: TaskRunResultType.Error,
+ errorDetail: getErrorDetailFromException(e),
+ };
+ }
if (info.cts.token.isCancelled) {
logger.info("task cancelled, not processing result");
return;
@@ -521,36 +519,6 @@ async function storePendingTaskFinished(
});
}
-async function runTaskWithErrorReporting(
- ws: InternalWalletState,
- opId: TaskIdStr,
- info: ShepherdInfo,
- f: () => Promise<TaskRunResult>,
-): Promise<TaskRunResult> {
- try {
- return await f();
- } catch (e) {
- if (e instanceof CryptoApiStoppedError) {
- if (ws.stopped) {
- logger.warn("crypto API stopped during shutdown, ignoring error");
- return {
- type: TaskRunResultType.Error,
- errorDetail: makeErrorDetail(
- TalerErrorCode.WALLET_UNEXPECTED_EXCEPTION,
- {},
- "Crypto API stopped during shutdown",
- ),
- };
- }
- }
- const errorDetail = getErrorDetailFromException(e);
- return {
- type: TaskRunResultType.Error,
- errorDetail,
- };
- }
-}
-
function getWalletExecutionContextForTask(
ws: InternalWalletState,
taskId: TaskIdStr,