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";
22import type { FastifyInstance } from "fastify" ;
33import { StatusCodes } from "http-status-codes" ;
44import { getContract } from "../../../../utils/cache/getContract" ;
5+ import { prettifyError } from "../../../../utils/error" ;
56import { createCustomError } from "../../../middleware/error" ;
67import {
78 readRequestQuerySchema ,
@@ -64,22 +65,16 @@ export async function readContract(fastify: FastifyInstance) {
6465 } ) ;
6566
6667 let returnData : unknown ;
67-
6868 try {
6969 returnData = await contract . call ( functionName , parsedArgs ?? [ ] ) ;
7070 } 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+ ) ;
8276 }
77+
8378 returnData = bigNumberReplacer ( returnData ) ;
8479
8580 reply . status ( StatusCodes . OK ) . send ( {
You can’t perform that action at this time.
0 commit comments