Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions apps/common/frontend/src/contexts/LedgerApiContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ interface JsonApiErrorResponse {
body: JsonApiErrorBody;
}

interface JsCantonError {
code: string;
cause: string;
correlationId: string;
}

interface JsonApiErrorBody {
error: string;
error: JsCantonError;
}

export class JsonApiError extends Error {
Expand Down Expand Up @@ -169,7 +175,7 @@ export class LedgerApiClient {
console.debug(`${describeChoice} succeeded.`);
return r.json();
} else {
const body = await r.text();
const body = JSON.parse(await r.text());
throw new JsonApiError({
status: r.status,
body: { error: body },
Expand Down
2 changes: 1 addition & 1 deletion apps/common/frontend/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const retrySynchronizerError = (failureCount: number, error: Error): bool
// because that then also retries on invalid user input.
const errResponse = error as JsonApiError;
const keywords = ['NOT_CONNECTED_TO_SYNCHRONIZER', 'NOT_CONNECTED_TO_ANY_SYNCHRONIZER'];
const isDomainConnectionError = keywords.some(k => errResponse.body?.error?.includes(k));
const isDomainConnectionError = keywords.some(k => errResponse.body?.error?.code.includes(k));

return isDomainConnectionError && failureCount < 10;
};
Loading