| 26 | // decode — which only sees own properties — would miss the very sentence the |
| 27 | // server wrote for the user. Read the property directly. |
| 28 | const decodeErrorMessage = (value: unknown): Option.Option<{ readonly message: string }> => { |
| 29 | if (typeof value !== "object" || value === null) return Option.none(); |
| 30 | const message: unknown = Reflect.get(value, "message"); |
| 31 | return typeof message === "string" && message.length > 0 |
| 32 | ? Option.some({ message }) |
| 33 | : Option.none(); |
| 34 | }; |
| 35 | |
| 36 | const TaggedValue = Schema.Struct({ _tag: Schema.String }); |
| 37 | const decodeTaggedValue = Schema.decodeUnknownOption(TaggedValue); |