Skip to content

Commit df71f21

Browse files
committed
refactor: improve error handling in user service and ensure consistent error throwing
1 parent b98a041 commit df71f21

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/backend/src/song/song-webhook/song-webhook.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export class SongWebhookService implements OnModuleInit {
4848
body: JSON.stringify(webhookData),
4949
});
5050

51-
const data = await response.json();
51+
const data = (await response.json()) as { id: string };
5252

5353
//this.logger.log(`Posted webhook message for song ${song.publicId}`);
5454
return data.id; // Discord message ID

apps/backend/src/user/user.service.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export class UserService {
3232
new: true, // return the updated document
3333
})) as UserDocument;
3434
} catch (error) {
35-
throw new Error(error);
35+
if (error instanceof Error) {
36+
throw error;
37+
}
38+
39+
throw new Error(String(error));
3640
}
3741
}
3842

0 commit comments

Comments
 (0)