Skip to content

Commit

Permalink
Check cause?.data on getParsedError (#649)
Browse files Browse the repository at this point in the history
  • Loading branch information
technophile-04 authored Dec 7, 2023
1 parent fe7024a commit 4a403ee
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ const getParsedError = (e: any): string => {
message = e.details;
} else if (e.shortMessage) {
message = e.shortMessage;
const cause = e.cause as { data?: DecodeErrorResultReturnType };
const cause = e.cause as { data?: DecodeErrorResultReturnType } | undefined;
// if its not generic error, append custom error name and its args to message
if (cause.data && cause.data?.abiItem?.name !== "Error") {
if (cause?.data && cause.data?.abiItem?.name !== "Error") {
const customErrorArgs = cause.data.args?.toString() ?? "";
message = `${message.replace(/reverted\.$/, "reverted with following reason:")}\n${
cause.data.errorName
Expand Down

0 comments on commit 4a403ee

Please sign in to comment.