mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-04 11:56:13 +02:00
Better error handling
This commit is contained in:
@@ -7,10 +7,10 @@ import { Note } from '../../../models/entities/note';
|
||||
|
||||
export async function deliverQuestionUpdate(noteId: Note['id']) {
|
||||
const note = await Notes.findOne(noteId);
|
||||
if (note == null) throw 'note not found';
|
||||
if (note == null) throw new Error('note not found');
|
||||
|
||||
const user = await Users.findOne(note.userId);
|
||||
if (user == null) throw 'note not found';
|
||||
if (user == null) throw new Error('note not found');
|
||||
|
||||
const followers = await Followings.find({
|
||||
followeeId: user.id
|
||||
|
||||
@@ -10,7 +10,7 @@ import { createNotification } from '../../create-notification';
|
||||
export default async function(user: User, note: Note, choice: number) {
|
||||
const poll = await Polls.findOne(note.id);
|
||||
|
||||
if (poll == null) throw 'poll not found';
|
||||
if (poll == null) throw new Error('poll not found');
|
||||
|
||||
// Check whether is valid choice
|
||||
if (poll.choices[choice] == null) throw new Error('invalid choice param');
|
||||
|
||||
Reference in New Issue
Block a user