Improve error handling of API (#4345)

* wip

* wip

* wip

* Update attached_notes.ts

* wip

* Refactor

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* Update call.ts

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* ✌️

* Fix
This commit is contained in:
syuilo 2019-02-22 11:46:58 +09:00 committed by GitHub
parent fc52e95ad0
commit 2756f553c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
181 changed files with 2010 additions and 1322 deletions

View file

@ -15,6 +15,7 @@ import Instance from '../../models/instance';
import instanceChart from '../../services/chart/instance';
import Logger from '../../misc/logger';
import FollowRequest from '../../models/follow-request';
import { IdentifiableError } from '../../misc/identifiable-error';
const logger = new Logger('following/create');
@ -142,8 +143,8 @@ export default async function(follower: IUser, followee: IUser, requestId?: stri
});
} else {
// それ以外は単純に例外
if (blocking != null) throw new Error('blocking');
if (blocked != null) throw new Error('blocked');
if (blocking != null) throw new IdentifiableError('710e8fb0-b8c3-4922-be49-d5d93d8e6a6e', 'blocking');
if (blocked != null) throw new IdentifiableError('3338392a-f764-498d-8855-db939dcf8c48', 'blocked');
}
// フォロー対象が鍵アカウントである or

View file

@ -5,6 +5,7 @@ import renderFollow from '../../../remote/activitypub/renderer/follow';
import renderUndo from '../../../remote/activitypub/renderer/undo';
import { deliver } from '../../../queue';
import { publishMainStream } from '../../stream';
import { IdentifiableError } from '../../../misc/identifiable-error';
export default async function(followee: IUser, follower: IUser) {
if (isRemoteUser(followee)) {
@ -18,7 +19,7 @@ export default async function(followee: IUser, follower: IUser) {
});
if (request == null) {
throw 'request not found';
throw new IdentifiableError('17447091-ce07-46dd-b331-c1fd4f15b1e7', 'request not found');
}
await FollowRequest.remove({