mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-20 19:06:22 +00:00
rename unavailable image resizer error
This commit is contained in:
@@ -11,12 +11,12 @@ const AUTO_RESIZE = true
|
||||
const JPEG_QUALITIES = [80, 85, 70, 55, 40]
|
||||
const log = Log.create({ service: "image" })
|
||||
|
||||
export class PhotonUnavailableError extends Schema.TaggedErrorClass<PhotonUnavailableError>()(
|
||||
"ImagePhotonUnavailableError",
|
||||
export class ResizerUnavailableError extends Schema.TaggedErrorClass<ResizerUnavailableError>()(
|
||||
"ImageResizerUnavailableError",
|
||||
{},
|
||||
) {
|
||||
override get message() {
|
||||
return "Photon image processor is unavailable"
|
||||
return "Image resizer is unavailable"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export class SizeError extends Schema.TaggedErrorClass<SizeError>()("ImageSizeEr
|
||||
}
|
||||
}
|
||||
|
||||
export type Error = PhotonUnavailableError | InvalidDataUrlError | DecodeError | SizeError
|
||||
export type Error = ResizerUnavailableError | InvalidDataUrlError | DecodeError | SizeError
|
||||
|
||||
export interface Interface {
|
||||
readonly normalize: (input: MessageV2.FilePart) => Effect.Effect<MessageV2.FilePart, Error>
|
||||
@@ -89,7 +89,7 @@ export const layer = Layer.effect(
|
||||
if (bytes <= info.maxBase64Bytes) return input
|
||||
|
||||
const photon = yield* loadPhoton
|
||||
if (!photon) return yield* new PhotonUnavailableError()
|
||||
if (!photon) return yield* new ResizerUnavailableError()
|
||||
|
||||
const decoded = yield* Effect.try({
|
||||
try: () => photon.PhotonImage.new_from_byteslice(Buffer.from(base64, "base64")),
|
||||
|
||||
@@ -408,7 +408,7 @@ export const layer: Layer.Layer<
|
||||
.normalize(attachment)
|
||||
.pipe(
|
||||
Effect.catchIf(
|
||||
(error) => error instanceof Image.PhotonUnavailableError,
|
||||
(error) => error instanceof Image.ResizerUnavailableError,
|
||||
() => Effect.succeed(attachment),
|
||||
),
|
||||
Effect.exit,
|
||||
|
||||
@@ -1296,7 +1296,7 @@ NOTE: At any point in time through this workflow you should feel free to ask the
|
||||
part.type === "file" && part.mime.startsWith("image/")
|
||||
? image.normalize(part).pipe(
|
||||
Effect.catchIf(
|
||||
(error) => error instanceof Image.PhotonUnavailableError,
|
||||
(error) => error instanceof Image.ResizerUnavailableError,
|
||||
() => Effect.succeed(part),
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user