Improve error handling

This commit is contained in:
tdurieux
2026-05-06 16:45:22 +03:00
parent 3613c895c8
commit dcb524c8c1
10 changed files with 72 additions and 12 deletions
+4
View File
@@ -12,6 +12,7 @@ export default class AnonymousError extends CustomError {
value?: unknown;
httpStatus?: number;
cause?: Error;
private explicitUrl?: string;
constructor(
message: string,
@@ -19,15 +20,18 @@ export default class AnonymousError extends CustomError {
httpStatus?: number;
cause?: Error;
object?: unknown;
url?: string;
}
) {
super(message);
this.value = opt?.object;
this.httpStatus = opt?.httpStatus;
this.cause = opt?.cause;
this.explicitUrl = opt?.url;
}
url(): string | undefined {
if (this.explicitUrl) return this.explicitUrl;
if (this.value == null) return undefined;
try {
if (this.value instanceof AnonymizedFile) {
+1 -1
View File
@@ -163,7 +163,7 @@ export default class S3Storage extends StorageBase {
if (!res) {
throw new AnonymousError("file_not_found", {
httpStatus: 404,
object: join(this.repoPath(repoId), path),
url: join(this.repoPath(repoId), path),
});
}
return res as Readable;