Better error handling
This commit is contained in:
parent
b390363b25
commit
e3b3f8fac1
25 changed files with 52 additions and 52 deletions
|
|
@ -297,7 +297,7 @@ export default async function(
|
|||
// If usage limit exceeded
|
||||
if (usage + size > driveCapacity) {
|
||||
if (Users.isLocalUser(user)) {
|
||||
throw 'no-free-space';
|
||||
throw new Error('no-free-space');
|
||||
} else {
|
||||
// (アバターまたはバナーを含まず)最も古いファイルを削除する
|
||||
deleteOldFile(user as IRemoteUser);
|
||||
|
|
@ -316,7 +316,7 @@ export default async function(
|
|||
userId: user.id
|
||||
});
|
||||
|
||||
if (driveFolder == null) throw 'folder-not-found';
|
||||
if (driveFolder == null) throw new Error('folder-not-found');
|
||||
|
||||
return driveFolder;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ export async function removePinned(user: User, noteId: Note['id']) {
|
|||
|
||||
export async function deliverPinnedChange(userId: User['id'], noteId: Note['id'], isAddition: boolean) {
|
||||
const user = await Users.findOne(userId);
|
||||
if (user == null) throw 'user not found';
|
||||
if (user == null) throw new Error('user not found');
|
||||
|
||||
if (!Users.isLocalUser(user)) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { renderPerson } from '../../remote/activitypub/renderer/person';
|
|||
|
||||
export async function publishToFollowers(userId: User['id']) {
|
||||
const user = await Users.findOne(userId);
|
||||
if (user == null) throw 'user not found';
|
||||
if (user == null) throw new Error('user not found');
|
||||
|
||||
const followers = await Followings.find({
|
||||
followeeId: user.id
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
|||
}
|
||||
|
||||
if (data.visibility == 'specified') {
|
||||
if (data.visibleUsers == null) throw 'invalid param';
|
||||
if (data.visibleUsers == null) throw new Error('invalid param');
|
||||
|
||||
for (const u of data.visibleUsers) {
|
||||
if (!mentionedUsers.some(x => x.id === u.id)) {
|
||||
|
|
@ -214,7 +214,7 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
|
|||
|
||||
// 未読通知を作成
|
||||
if (data.visibility == 'specified') {
|
||||
if (data.visibleUsers == null) throw 'invalid param';
|
||||
if (data.visibleUsers == null) throw new Error('invalid param');
|
||||
|
||||
for (const u of data.visibleUsers) {
|
||||
insertNoteUnread(u, note, true);
|
||||
|
|
@ -428,7 +428,7 @@ async function insertNote(user: User, data: Option, tags: string[], emojis: stri
|
|||
|
||||
console.error(e);
|
||||
|
||||
throw 'something happened';
|
||||
throw new Error('something happened');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue