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

@@ -1,7 +1,6 @@
import * as Log from "@opencode-ai/core/util/log"
import path from "path"
import { Global } from "@opencode-ai/core/global"
import { NamedError } from "@opencode-ai/core/util/error"
import { AppFileSystem } from "@opencode-ai/core/filesystem"
import { Effect, Exit, Layer, Option, RcMap, Schema, Context, TxReentrantLock } from "effect"
import { NonNegativeInt } from "@opencode-ai/core/schema"
@@ -15,11 +14,22 @@ type Migration = (
git: Git.Interface,
) => Effect.Effect<void, AppFileSystem.Error>
export const NotFoundError = NamedError.create("NotFoundError", {
export class NotFoundError extends Schema.TaggedErrorClass<NotFoundError>()("NotFoundError", {
message: Schema.String,
})
}) {
static isInstance(input: unknown): input is NotFoundError {
return input instanceof NotFoundError
}
export type Error = AppFileSystem.Error | InstanceType<typeof NotFoundError>
toObject() {
return {
name: "NotFoundError" as const,
data: { message: this.message },
}
}
}
export type Error = AppFileSystem.Error | NotFoundError
const RootFile = Schema.Struct({
path: Schema.optional(
@@ -245,7 +255,7 @@ export const layer = Layer.effect(
}),
)
const fail = (target: string): Effect.Effect<never, InstanceType<typeof NotFoundError>> =>
const fail = (target: string): Effect.Effect<never, NotFoundError> =>
Effect.fail(new NotFoundError({ message: `Resource not found: ${target}` }))
const wrap = <A>(target: string, body: Effect.Effect<A, AppFileSystem.Error>) =>