Skip to content

Commit 97ed459

Browse files
committed
fix: error message display
1 parent dede265 commit 97ed459

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/containers/Inspector.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ import { JSONRPCError } from "@open-rpc/client-js/build/Error";
1010
import { MethodObject } from "@open-rpc/meta-schema";
1111
import MonacoEditor from "@etclabscore/react-monaco-editor";
1212

13+
const errorToJSON = (error: JSONRPCError | undefined): any => {
14+
if (!error) {
15+
return;
16+
}
17+
return {
18+
code: error.code,
19+
message: error.message,
20+
data: error.data,
21+
};
22+
};
23+
1324
interface IProps {
1425
url?: string;
1526
request?: any;
@@ -127,7 +138,6 @@ const Inspector: React.FC<IProps> = (props) => {
127138
}
128139
};
129140

130-
131141
return (
132142
<>
133143
<AppBar elevation={0} position="static">
@@ -200,7 +210,7 @@ const Inspector: React.FC<IProps> = (props) => {
200210
height="93vh"
201211
editorDidMount={handleResponseEditorDidMount}
202212
language="json"
203-
value={JSON.stringify(error || results, null, 4) || ""}
213+
value={JSON.stringify(errorToJSON(error) || results, null, 4) || ""}
204214
/>
205215
</>
206216
</SplitPane>

0 commit comments

Comments
 (0)