Handling Error States in effect-http with Type Checking for API Responses

I'm having an issue recovering from an error state in effect-http.

I have a route, that if i don't handle my errors - is type checking. So I have a spec defined with two possible responses, a 200 response & body and a 401 response & body.

basically like this

Api.setResponseBody(DavinciFlowNode),
Api.addResponse(ApiResponse.make(401, TemporaryErrorBody)),


My understanding is, I need my route to return one of these shapes at least.

and this code here is what i'm basically trying to do

return yield* post('/customHtmlTemplate', { headers, query, body }).pipe(
        Effect.andThen((result) => result),
        //Effect.catchTags({
        //  UnableToFindNextStep: () =>
        //    Effect.succeed({
        //      status: 401 as const,
        //      message: 'Authorization Failure, unable to find next step in journey',
        //    }),
        //  //    InvalidUsernamePassword: () =>
        //  //      Effect.succeed({
        //  //        status: 401 as const,
        //  //        message: 'Authorization Failure, Invalid username or password',
        //  //      }),
        //}),
      );


So the commented out code, trying to recover from possible error states, is what makes typescript upset. Its basically saying its missing types from the Success channel of that effect that I yield.

I thought that if my post errors, i would catch the tags that it throws and return the error shape I defined.
Was this page helpful?