Skip to content

Commit 3d42edc

Browse files
committed
refactor(kleros-sdk): address-coderabbit-feedback
1 parent 542a8d9 commit 3d42edc

File tree

3 files changed

+27
-31
lines changed

3 files changed

+27
-31
lines changed

kleros-sdk/src/errors/index.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
export class InvalidContextError extends Error {
2-
constructor(message: string) {
1+
export class CustomError extends Error {
2+
constructor(name: string, message: string) {
33
super(message);
4-
this.name = "InvalidContextError";
4+
this.name = name;
55

66
if (Error.captureStackTrace) {
77
Error.captureStackTrace(this, this.constructor);
88
}
99
}
1010
}
1111

12-
export class InvalidMappingError extends Error {
12+
export class InvalidContextError extends CustomError {
1313
constructor(message: string) {
14-
super(message);
15-
this.name = "InvalidMappingError";
14+
super("InvalidContextError", message);
15+
}
16+
}
1617

17-
if (Error.captureStackTrace) {
18-
Error.captureStackTrace(this, this.constructor);
19-
}
18+
export class InvalidMappingError extends CustomError {
19+
constructor(message: string) {
20+
super("InvalidMappingError", message);
2021
}
2122
}
2223

@@ -48,14 +49,9 @@ export class RequestError extends Error {
4849
}
4950
}
5051

51-
export class UnsupportedActionError extends Error {
52+
export class UnsupportedActionError extends CustomError {
5253
constructor(message: string) {
53-
super(message);
54-
this.name = "UnsupportedActionError";
55-
56-
if (Error.captureStackTrace) {
57-
Error.captureStackTrace(this, this.constructor);
58-
}
54+
super("UnsupportedActionError", message);
5955
}
6056
}
6157

kleros-sdk/src/requests/fetchDisputeDetails.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { request } from "graphql-request";
1+
import { request, gql } from "graphql-request";
22
import { RequestError } from "../errors";
33

44
type DisputeDetailsQueryResponse = {
@@ -13,18 +13,18 @@ type DisputeDetailsQueryResponse = {
1313
};
1414

1515
const fetchDisputeDetails = async (endpoint: string, id: bigint) => {
16-
const query = `
17-
query DisputeDetails($id: ID!) {
18-
dispute(id: $id) {
16+
const query = gql`
17+
query DisputeDetails($id: ID!) {
18+
dispute(id: $id) {
1919
arbitrated {
20-
id
20+
id
2121
}
2222
arbitrableChainId
2323
externalDisputeId
2424
templateId
25+
}
2526
}
26-
}
27-
`;
27+
`;
2828
const variables = { id: Number(id) };
2929

3030
try {

kleros-sdk/src/requests/fetchDisputeTemplateFromId.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { request } from "graphql-request";
1+
import { request, gql } from "graphql-request";
22
import { RequestError } from "../errors";
33

44
type DisputeTemplateQueryResponse = {
@@ -9,14 +9,14 @@ type DisputeTemplateQueryResponse = {
99
};
1010

1111
const fetchDisputeTemplateFromId = async (endpoint: string, id: number) => {
12-
const query = `
13-
query DisputeTemplate ($id: ID!) {
14-
disputeTemplate(id: $id) {
15-
templateData
16-
templateDataMappings
17-
}
12+
const query = gql`
13+
query DisputeTemplate($id: ID!) {
14+
disputeTemplate(id: $id) {
15+
templateData
16+
templateDataMappings
17+
}
1818
}
19-
`;
19+
`;
2020

2121
const variables = { id: id.toString() };
2222
try {

0 commit comments

Comments
 (0)