-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1762 from kleros/chore/parse-wagmi-simulate-error
chore(web): better-error-display-and-evidence-search
- Loading branch information
Showing
9 changed files
with
90 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { type SimulateContractErrorType } from "@wagmi/core"; | ||
|
||
type ExtendedWagmiError = SimulateContractErrorType & { shortMessage?: string; metaMessages?: string[] }; | ||
|
||
/** | ||
* @param error | ||
* @description Tries to extract the human readable error message, otherwise reverts to error.message | ||
* @returns Human readable error if possible | ||
*/ | ||
export const parseWagmiError = (error: SimulateContractErrorType) => { | ||
const extError = error as ExtendedWagmiError; | ||
|
||
const metaMessage = extError?.metaMessages?.[0]; | ||
const shortMessage = extError?.shortMessage; | ||
|
||
return metaMessage ?? shortMessage ?? error.message; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { type SimulateContractErrorType } from "@wagmi/core"; | ||
|
||
type ExtendedWagmiError = SimulateContractErrorType & { shortMessage?: string; metaMessages?: string[] }; | ||
|
||
/** | ||
* @param error | ||
* @description Tries to extract the human readable error message, otherwise reverts to error.message | ||
* @returns Human readable error if possible | ||
*/ | ||
export const parseWagmiError = (error: SimulateContractErrorType) => { | ||
const extError = error as ExtendedWagmiError; | ||
|
||
const metaMessage = extError?.metaMessages?.[0]; | ||
const shortMessage = extError?.shortMessage; | ||
|
||
return metaMessage ?? shortMessage ?? error.message; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* | ||
* @param searchString | ||
* @returns A search string to better search with fullTextSearch | ||
*/ | ||
export const transformSearch = (searchString?: string) => { | ||
if (!searchString) return null; | ||
const words = searchString | ||
.split(/\s+/) | ||
.map((word) => word.trim()) | ||
.filter(Boolean); | ||
|
||
const transformedWords = words.map((word) => `${word} | ${word}:*`); | ||
|
||
return transformedWords.join(" | "); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters