Skip to content

Commit a387e77

Browse files
committed
refactor(kleros-sdk): refactor-error-classes
1 parent 3d42edc commit a387e77

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

kleros-sdk/src/errors/index.ts

+8-29
Original file line numberDiff line numberDiff line change
@@ -21,31 +21,20 @@ export class InvalidMappingError extends CustomError {
2121
}
2222
}
2323

24-
export class NotFoundError extends Error {
24+
export class NotFoundError extends CustomError {
2525
public resourceName: string;
2626

2727
constructor(resourceName: string, message: string) {
28-
super(message);
29-
this.name = "NotFoundError";
28+
super("NotFoundError", message);
3029
this.resourceName = resourceName;
31-
32-
if (Error.captureStackTrace) {
33-
Error.captureStackTrace(this, this.constructor);
34-
}
3530
}
3631
}
37-
38-
export class RequestError extends Error {
32+
export class RequestError extends CustomError {
3933
public endpoint: string | undefined;
4034

4135
constructor(message: string, endpoint?: string) {
42-
super(message);
43-
this.name = "RequestError";
36+
super("RequestError", message);
4437
this.endpoint = endpoint;
45-
46-
if (Error.captureStackTrace) {
47-
Error.captureStackTrace(this, this.constructor);
48-
}
4938
}
5039
}
5140

@@ -55,24 +44,14 @@ export class UnsupportedActionError extends CustomError {
5544
}
5645
}
5746

58-
export class InvalidFormatError extends Error {
47+
export class InvalidFormatError extends CustomError {
5948
constructor(message: string) {
60-
super(message);
61-
this.name = "InvalidFormatError";
62-
63-
if (Error.captureStackTrace) {
64-
Error.captureStackTrace(this, this.constructor);
65-
}
49+
super("InvalidFormatError", message);
6650
}
6751
}
6852

69-
export class SdkNotConfiguredError extends Error {
53+
export class SdkNotConfiguredError extends CustomError {
7054
constructor() {
71-
super("SDK not configured. Please call `configureSDK` before using.");
72-
this.name = "SdkNotConfiguredError";
73-
74-
if (Error.captureStackTrace) {
75-
Error.captureStackTrace(this, this.constructor);
76-
}
55+
super("SdkNotConfiguredError", "SDK not configured. Please call `configureSDK` before using.");
7756
}
7857
}

kleros-sdk/src/requests/fetchDisputeDetails.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const fetchDisputeDetails = async (endpoint: string, id: bigint) => {
2525
}
2626
}
2727
`;
28-
const variables = { id: Number(id) };
28+
const variables = { id: id.toString() };
2929

3030
try {
3131
return await request<DisputeDetailsQueryResponse>(endpoint, query, variables);

0 commit comments

Comments
 (0)