MCPcopy Create free account
hub / github.com/Effect-TS/effect / causePrettyMessage

Function causePrettyMessage

packages/effect/src/internal/effect.ts:388–403  ·  view source on GitHub ↗
(u: Record<string, unknown> | Error)

Source from the content-addressed store, hash-verified

386}
387
388const causePrettyMessage = (u: Record<string, unknown> | Error): string => {
389 if (typeof u.message === "string") {
390 return u.message
391 } else if (
392 typeof u.toString === "function"
393 && u.toString !== Object.prototype.toString
394 && u.toString !== Array.prototype.toString
395 ) {
396 try {
397 return u.toString()
398 } catch {
399 // something's off, rollback to json
400 }
401 }
402 return formatJson(u)
403}
404
405const locationRegExp = /\((.*)\)/g
406

Callers 1

causePrettyErrorFunction · 0.85

Calls 2

formatJsonFunction · 0.90
toStringMethod · 0.65

Tested by

no test coverage detected