Effector Error Handling Challenge

Hey all,

I'm doing some beginning work with Effect, trying to get the hang of a few things.

I'm trying to make a basic API that interfaces with some public API's. I have this endpoint:

const getMusic = Api.get("getMusic", "/music").pipe(
  Api.setResponseBody(SearchResult),
  Api.addResponse(ApiResponse.make(500, ...))
);


And this code, where I've attempted to implement some error handling:

const getArtist = Http.request
  .get("https://musicbrainz.org/ws/2/artist/?query=ac%5C%2Fdc")
  .pipe(
    Http.client.fetch,
    Effect.andThen(Http.response.schemaBodyJson(SearchResult)),
    Effect.catchTag("ParseError", (e) => Effect.succeed({ content: { e }, status: 500 as const })),
    Effect.tap(Console.log),
    Effect.scoped
  );

export const getMusicLive = RouterBuilder.handler(
  api,
  "getMusic",
  () => getArtist
);


However, getArtist in getMusicLive errors, as it is expecting proper typing for the handled error.

I'm attempting to add it in Api.addResponse in getMusic, but I am unsure what to put after the 500. I tried a few things with Schemas, like using a Struct, but that didn't seem to work.
Was this page helpful?