File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
src/server/routes/contract/read Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { Type } from "@sinclair/typebox";
2
2
import type { FastifyInstance } from "fastify" ;
3
3
import { StatusCodes } from "http-status-codes" ;
4
4
import { getContract } from "../../../../utils/cache/getContract" ;
5
+ import { prettifyError } from "../../../../utils/error" ;
5
6
import { createCustomError } from "../../../middleware/error" ;
6
7
import {
7
8
readRequestQuerySchema ,
@@ -64,22 +65,16 @@ export async function readContract(fastify: FastifyInstance) {
64
65
} ) ;
65
66
66
67
let returnData : unknown ;
67
-
68
68
try {
69
69
returnData = await contract . call ( functionName , parsedArgs ?? [ ] ) ;
70
70
} catch ( e ) {
71
- if (
72
- e instanceof Error &&
73
- ( e . message . includes ( "is not a function" ) ||
74
- e . message . includes ( "arguments, but" ) )
75
- ) {
76
- throw createCustomError (
77
- e . message ,
78
- StatusCodes . BAD_REQUEST ,
79
- "BAD_REQUEST" ,
80
- ) ;
81
- }
71
+ throw createCustomError (
72
+ prettifyError ( e ) ,
73
+ StatusCodes . BAD_REQUEST ,
74
+ "BAD_REQUEST" ,
75
+ ) ;
82
76
}
77
+
83
78
returnData = bigNumberReplacer ( returnData ) ;
84
79
85
80
reply . status ( StatusCodes . OK ) . send ( {
You can’t perform that action at this time.
0 commit comments