MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / makeError

Function makeError

ses.cjs:1691–1713  ·  view source on GitHub ↗
(
  optDetails=  redactedDetails `Assert failed`,
  ErrorConstructor=  globalThis.Error,
  { errorName=  undefined}=   {})

Source from the content-addressed store, hash-verified

1689 * @type {AssertMakeError}
1690 */
1691const makeError= (
1692 optDetails= redactedDetails `Assert failed`,
1693 ErrorConstructor= globalThis.Error,
1694 { errorName= undefined}= {})=>
1695 {
1696 if( typeof optDetails=== 'string') {
1697 // If it is a string, use it as the literal part of the template so
1698 // it doesn't get quoted.
1699 optDetails= redactedDetails([optDetails]);
1700 }
1701 const hiddenDetails= weakmapGet(hiddenDetailsMap, optDetails);
1702 if( hiddenDetails=== undefined) {
1703 throw TypeError( `unrecognized details ${quote(optDetails)}`);
1704 }
1705 const messageString= getMessageString(hiddenDetails);
1706 const error= new ErrorConstructor(messageString);
1707 weakmapSet(hiddenMessageLogArgs, error, getLogArgs(hiddenDetails));
1708 if( errorName!== undefined) {
1709 tagError(error, errorName);
1710 }
1711 // The next line is a particularly fruitful place to put a breakpoint.
1712 return error;
1713 };
1714freeze(makeError);
1715
1716// /////////////////////////////////////////////////////////////////////////////

Callers 1

failFunction · 0.85

Calls 5

redactedDetailsFunction · 0.85
quoteFunction · 0.85
getMessageStringFunction · 0.85
getLogArgsFunction · 0.85
tagErrorFunction · 0.85

Tested by

no test coverage detected