MCPcopy
hub / github.com/Effect-TS/effect / prettyErrorMessage

Function prettyErrorMessage

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

Source from the content-addressed store, hash-verified

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

Callers 1

makePrettyErrorFunction · 0.85

Calls 2

isFunctionFunction · 0.85
stringifyCircularFunction · 0.85

Tested by

no test coverage detected