diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2025-05-22 10:53:38 -0400 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-06-06 22:20:17 -0400 |
| commit | 6627e8a9b848473740a8e9b9864520701226179c (patch) | |
| tree | 7972ff9aed2460e2bbf91fa8ebc8e8500a530b92 /packages/backend/src/server/FileServerService.ts | |
| parent | normalize use of .info (INFO) instead of .succ (DONE) logging (diff) | |
| download | sharkey-6627e8a9b848473740a8e9b9864520701226179c.tar.gz sharkey-6627e8a9b848473740a8e9b9864520701226179c.tar.bz2 sharkey-6627e8a9b848473740a8e9b9864520701226179c.zip | |
add more details to StatusErrors
Diffstat (limited to 'packages/backend/src/server/FileServerService.ts')
| -rw-r--r-- | packages/backend/src/server/FileServerService.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts index e5d8f39e5a..1a372cb789 100644 --- a/packages/backend/src/server/FileServerService.ts +++ b/packages/backend/src/server/FileServerService.ts @@ -384,7 +384,7 @@ export class FileServerService { ) { if (!isConvertibleImage) { // 画像でないなら404でお茶を濁す - throw new StatusError('Unexpected mime', 404); + throw new StatusError(`Unexpected non-convertible mime: ${file.mime}`, 404, 'Unexpected mime'); } } @@ -448,7 +448,7 @@ export class FileServerService { } else if (file.mime === 'image/svg+xml') { image = this.imageProcessingService.convertToWebpStream(file.path, 2048, 2048); } else if (!file.mime.startsWith('image/') || !FILE_TYPE_BROWSERSAFE.includes(file.mime)) { - throw new StatusError('Rejected type', 403, 'Rejected type'); + throw new StatusError(`Blocked mime type: ${file.mime}`, 403, 'Blocked mime type'); } if (!image) { @@ -522,7 +522,7 @@ export class FileServerService { > { if (url.startsWith(`${this.config.url}/files/`)) { const key = url.replace(`${this.config.url}/files/`, '').split('/').shift(); - if (!key) throw new StatusError('Invalid File Key', 400, 'Invalid File Key'); + if (!key) throw new StatusError(`Invalid file URL ${url}`, 400, 'Invalid file url'); return await this.getFileFromKey(key); } |