Skip to content

Commit

Permalink
fix YieldableError rendering on bun (#3295)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jul 18, 2024
1 parent cc327a1 commit 2b14d18
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/unlucky-peaches-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

fix YieldableError rendering on bun
12 changes: 8 additions & 4 deletions packages/effect/src/internal/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type * as MetricLabel from "../MetricLabel.js"
import * as MutableRef from "../MutableRef.js"
import * as Option from "../Option.js"
import { pipeArguments } from "../Pipeable.js"
import { hasProperty, isObject, isPromiseLike, isString, type Predicate, type Refinement } from "../Predicate.js"
import { hasProperty, isObject, isPromiseLike, type Predicate, type Refinement } from "../Predicate.js"
import type * as Request from "../Request.js"
import type * as BlockedRequests from "../RequestBlock.js"
import type * as RequestResolver from "../RequestResolver.js"
Expand Down Expand Up @@ -2186,6 +2186,8 @@ export const YieldableError: new(message?: string, options?: ErrorOptions) => Ca
[NodeInspectSymbol]() {
if (this.toString !== globalThis.Error.prototype.toString) {
return this.stack ? `${this.toString()}\n${this.stack.split("\n").slice(1).join("\n")}` : this.toString()
} else if ("Bun" in globalThis) {
return internalCause.pretty(internalCause.fail(this), { renderErrorCause: true })
}
return this
}
Expand Down Expand Up @@ -2311,12 +2313,14 @@ export const UnknownExceptionTypeId: Cause.UnknownExceptionTypeId = Symbol.for(
) as Cause.UnknownExceptionTypeId

/** @internal */
export const UnknownException: new(error: unknown, message?: string | undefined) => Cause.UnknownException =
export const UnknownException: new(cause: unknown, message?: string | undefined) => Cause.UnknownException =
(function() {
class UnknownException extends YieldableError {
readonly _tag = "UnknownException"
constructor(readonly error: unknown, message?: string) {
super(message ?? (hasProperty(error, "message") && isString(error.message) ? error.message : void 0))
readonly error: unknown
constructor(readonly cause: unknown, message?: string) {
super(message ?? "An unknown error occurred", { cause })
this.error = cause
}
}
Object.assign(UnknownException.prototype, {
Expand Down

0 comments on commit 2b14d18

Please sign in to comment.