rename unavailable image resizer error

This commit is contained in:
Aiden Cline
2026-05-10 22:12:15 -05:00
parent 93bed80ac2
commit 7f0b5dcbee
3 changed files with 7 additions and 7 deletions

View File

@@ -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")),

View File

@@ -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,

View File

@@ -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),
),
)