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

Function prettyErrorMessage

packages/effect/src/internal/cause.ts:950–974  ·  view source on GitHub ↗
(u: unknown)

Source from the content-addressed store, hash-verified

948 * @internal
949 */
950export const prettyErrorMessage = (u: unknown): string => {
951 // 1)
952 if (typeof u === "string") {
953 return u
954 }
955 // 2)
956 if (typeof u === "object" && u !== null && u instanceof Error) {
957 return u.message
958 }
959 // 3)
960 try {
961 if (
962 hasProperty(u, "toString") &&
963 isFunction(u["toString"]) &&
964 u["toString"] !== Object.prototype.toString &&
965 u["toString"] !== globalThis.Array.prototype.toString
966 ) {
967 return u["toString"]()
968 }
969 } catch {
970 // something's off, rollback to json
971 }
972 // 4)
973 return stringifyCircular(u)
974}
975
976const locationRegex = /\((.*)\)/g
977

Callers 1

makePrettyErrorFunction · 0.85

Calls 2

isFunctionFunction · 0.85
stringifyCircularFunction · 0.85

Tested by

no test coverage detected