It looks like you're on the right track with mapping your internal error to a `ParseError` within...

What is the correct ParseError to use in a situation like this?
const SessionFromToken = Schema.transformOrFail(Token, Session, {
  decode: (token, _, ast) =>
    users
      .identify(token)
      .pipe(Effect.catchAll(() => ParseResult.fail(new ParseResult.Type(ast, token, "Invalid token")))),
  encode: (session) => ParseResult.succeed(Token.make(session.token))
})

This schema takes a token and checks to see if a Session can be derived from it. Internally my users.identify function returns a TokenNotFound error and as I am using it in a schema, I would like to map it to a useful ParseError. Is this the correct way of doing it?
Was this page helpful?