fix(provider): type model not found errors (#27334)
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { Provider } from "@/provider/provider"
|
||||
import { iife } from "@/util/iife"
|
||||
import { NamedError } from "@opencode-ai/core/util/error"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
import { Cause, Effect } from "effect"
|
||||
@@ -23,14 +21,7 @@ export const errorLayer = HttpRouter.middleware<{ handles: unknown }>()((effect)
|
||||
log.error("failed", { error, cause: Cause.pretty(cause) })
|
||||
|
||||
if (error instanceof NamedError) {
|
||||
return Effect.succeed(
|
||||
HttpServerResponse.jsonUnsafe(error.toObject(), {
|
||||
status: iife(() => {
|
||||
if (error instanceof Provider.ModelNotFoundError) return 400
|
||||
return 500
|
||||
}),
|
||||
}),
|
||||
)
|
||||
return Effect.succeed(HttpServerResponse.jsonUnsafe(error.toObject(), { status: 500 }))
|
||||
}
|
||||
return Effect.succeed(
|
||||
HttpServerResponse.jsonUnsafe(
|
||||
|
||||
Reference in New Issue
Block a user