Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/api/src/handlers/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const ToolsHandlers = HttpApiBuilder.group(ExecutorApi, "tools", (handler
const executor = yield* ExecutorService;
const schema = yield* executor.tools.schema(path.toolId);
if (schema === null) {
return yield* Effect.fail(new ToolNotFoundError({ toolId: path.toolId }));
return yield* new ToolNotFoundError({ toolId: path.toolId });
}
return schema;
})),
Expand Down
21 changes: 13 additions & 8 deletions packages/core/api/src/oauth-popup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// ---------------------------------------------------------------------------

import { describe, expect, it } from "@effect/vitest";
import { Effect } from "effect";
import { Data, Effect, Schema } from "effect";

import {
OAUTH_POPUP_MESSAGE_TYPE,
Expand Down Expand Up @@ -169,16 +169,21 @@ describe("runOAuthCallback", () => {
});

it("renders a failure popup when completeOAuth fails and uses toErrorMessage", async () => {
class DomainError {
readonly _tag = "DomainError";
constructor(readonly message: string) {}
}
class DomainError extends Data.TaggedError("DomainError")<{
readonly message: string;
}> {}
const isDomainError = Schema.is(Schema.Struct({
_tag: Schema.Literal("DomainError"),
message: Schema.String,
}));
const html = await Effect.runPromise(
runOAuthCallback<GoogleAuth, DomainError, never>({
complete: () => Effect.fail(new DomainError("Code expired")),
complete: () => Effect.fail(new DomainError({ message: "Code expired" })),
urlParams: { state: "s1" },
toErrorMessage: (error) =>
error instanceof DomainError ? error.message : "unknown",
toErrorMessage: (error) => {
// oxlint-disable-next-line executor/no-unknown-error-message -- boundary: schema guard narrows the unknown popup callback error to the public test message
return isDomainError(error) ? error.message : "unknown";
},
channelName: "c",
}),
);
Expand Down
Loading