fix(storage): type not found errors (#27265)

This commit is contained in:
Shoubhit Dash
2026-05-13 12:25:04 +05:30
committed by GitHub
parent d93a06431e
commit e9a29e4908
6 changed files with 51 additions and 21 deletions

View File

@@ -2,8 +2,6 @@ import type { NotFoundError as StorageNotFoundError } from "@/storage/storage"
import { Effect } from "effect"
import * as ApiError from "../errors"
type StorageNotFound = InstanceType<typeof StorageNotFoundError>
export function mapStorageNotFound<A, R>(self: Effect.Effect<A, StorageNotFound, R>) {
return self.pipe(Effect.mapError((error) => ApiError.notFound(error.data.message)))
export function mapStorageNotFound<A, R>(self: Effect.Effect<A, StorageNotFoundError, R>) {
return self.pipe(Effect.mapError((error) => ApiError.notFound(error.message)))
}

View File

@@ -24,11 +24,14 @@ export const errorLayer = HttpRouter.middleware<{ handles: unknown }>()((effect)
const error = defect.defect
log.error("failed", { error, cause: Cause.pretty(cause) })
if (error instanceof NotFoundError) {
return Effect.succeed(HttpServerResponse.jsonUnsafe(error.toObject(), { status: 404 }))
}
if (error instanceof NamedError) {
return Effect.succeed(
HttpServerResponse.jsonUnsafe(error.toObject(), {
status: iife(() => {
if (error instanceof NotFoundError) return 404
if (error instanceof Provider.ModelNotFoundError) return 400
if (error.name === "ProviderAuthValidationFailed") return 400
if (error.name.startsWith("Worktree")) return 400