Skip to content

Commit 447b75d

Browse files
committed
fix: handle bigint in innerError data
1 parent a876875 commit 447b75d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/cardano-services/test/TxSubmit/TxSubmitHttpService.test.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ describe('TxSubmitHttpService', () => {
172172

173173
describe('healthy but failing submission', () => {
174174
describe('/submit', () => {
175-
const stubErrors = [new TxSubmissionError(TxSubmissionErrorCode.EmptyInputSet, null, 'Bad inputs')];
175+
const stubErrors = [
176+
new TxSubmissionError(
177+
TxSubmissionErrorCode.NonEmptyRewardAccount,
178+
{ nonEmptyRewardAccountBalance: { lovelace: 10n } },
179+
'Bad inputs'
180+
)
181+
];
176182

177183
beforeAll(async () => {
178184
txSubmitProvider = txSubmitProviderMock(

packages/util/src/errors.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { CustomError } from 'ts-custom-error';
2+
import { toSerializableObject } from './serializableObject';
23

34
export const formatErrorMessage = (reason: string, detail?: string) => reason + (detail ? ` (${detail})` : '');
45

56
interface ErrorLike {
67
message: string;
78
stack: string;
9+
data?: unknown;
810
}
911

1012
interface WithInnerError {
@@ -64,6 +66,10 @@ export class ComposableError<InnerError = unknown> extends CustomError {
6466
[firstLineOfInnerErrorStack, ...innerErrorStack] = innerError.stack.split(ComposableError.stackDelimiter);
6567

6668
message = `${message} due to\n ${firstLineOfInnerErrorStack}`;
69+
70+
if (innerError.data) {
71+
innerError.data = toSerializableObject(innerError.data);
72+
}
6773
}
6874

6975
if (typeof innerError === 'string') message = `${message} due to\n ${innerError}`;

0 commit comments

Comments
 (0)