Skip to content

Commit

Permalink
fix: error message display
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejonas committed Jan 22, 2020
1 parent dede265 commit 97ed459
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/containers/Inspector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ import { JSONRPCError } from "@open-rpc/client-js/build/Error";
import { MethodObject } from "@open-rpc/meta-schema";
import MonacoEditor from "@etclabscore/react-monaco-editor";

const errorToJSON = (error: JSONRPCError | undefined): any => {
if (!error) {
return;
}
return {
code: error.code,
message: error.message,
data: error.data,
};
};

interface IProps {
url?: string;
request?: any;
Expand Down Expand Up @@ -127,7 +138,6 @@ const Inspector: React.FC<IProps> = (props) => {
}
};


return (
<>
<AppBar elevation={0} position="static">
Expand Down Expand Up @@ -200,7 +210,7 @@ const Inspector: React.FC<IProps> = (props) => {
height="93vh"
editorDidMount={handleResponseEditorDidMount}
language="json"
value={JSON.stringify(error || results, null, 4) || ""}
value={JSON.stringify(errorToJSON(error) || results, null, 4) || ""}
/>
</>
</SplitPane>
Expand Down

0 comments on commit 97ed459

Please sign in to comment.