Skip to content

Commit

Permalink
improve /platform/WorkerError messages (#3223)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Jul 11, 2024
1 parent a16e9be commit 0623fca
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-pumas-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

improve /platform/WorkerError messages
13 changes: 6 additions & 7 deletions packages/platform/src/WorkerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import * as Schema from "@effect/schema/Schema"
import type * as Cause from "effect/Cause"
import * as Inspectable from "effect/Inspectable"
import * as Predicate from "effect/Predicate"
import * as internal from "./internal/workerError.js"

Expand Down Expand Up @@ -49,23 +50,21 @@ export class WorkerError extends Schema.TaggedError<WorkerError>()("WorkerError"
* @since 1.0.0
*/
static readonly encodeCause: (a: Cause.Cause<WorkerError>) => Schema.CauseEncoded<WorkerErrorFrom> = Schema
.encodeSync(
this.Cause
)
.encodeSync(this.Cause)

/**
* @since 1.0.0
*/
static readonly decodeCause: (u: Schema.CauseEncoded<WorkerErrorFrom>) => Cause.Cause<WorkerError> = Schema
.decodeSync(
this.Cause
)
.decodeSync(this.Cause)

/**
* @since 1.0.0
*/
get message() {
const message = this.error instanceof Error ? this.error.message : String(this.error)
const message = Predicate.hasProperty(this.error, "message")
? this.error.message
: Inspectable.toStringUnknown(this.error, undefined)
return `${this.reason}: ${message}`
}
}
Expand Down

0 comments on commit 0623fca

Please sign in to comment.