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

Function encodeReason

packages/effect/src/encoding/SchemaBinary.ts:3299–3318  ·  view source on GitHub ↗
(ctx: EncodeContext, layout: ReasonLayout, value: unknown, w: Writer)

Source from the content-addressed store, hash-verified

3297}
3298
3299function encodeReason(ctx: EncodeContext, layout: ReasonLayout, value: unknown, w: Writer) {
3300 const reason = value as Cause.Reason<unknown>
3301 switch (reason._tag) {
3302 case "Fail":
3303 w.byte(0)
3304 encodeValue(ctx, layout.error, reason.error, w)
3305 return
3306 case "Die":
3307 w.byte(1)
3308 encodeValue(ctx, layout.defect, reason.defect, w)
3309 return
3310 case "Interrupt":
3311 if (reason.fiberId === undefined) {
3312 w.byte(2)
3313 } else {
3314 w.byte(3)
3315 w.f64(reason.fiberId)
3316 }
3317 }
3318}
3319
3320// `keyBytes` stays undefined while every key is ASCII, where code unit order
3321// and length already match raw UTF-8.

Callers 1

encodeValueFunction · 0.85

Calls 3

encodeValueFunction · 0.70
byteMethod · 0.45
f64Method · 0.45

Tested by

no test coverage detected