Skip to content

Commit

Permalink
APIのリクエスト方法(websocket/HTTP)によって返ってくるエラーの内容に違いがある問題を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
mei23 committed Jan 30, 2020
1 parent f69bd6b commit cca3a72
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/server/api/stream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import readNote from '../../../services/note/read';
import Channel from './channel';
import channels from './channels';
import { EventEmitter } from 'events';
import { ApiError } from '../error';

/**
* Main stream connection
Expand Down Expand Up @@ -71,8 +72,16 @@ export default class Connection {
// 呼び出し
call(endpoint, user, this.app, payload.data).then(res => {
this.sendMessageToWs(`api:${payload.id}`, { res });
}).catch(e => {
this.sendMessageToWs(`api:${payload.id}`, { e });
}).catch((e: ApiError) => {
this.sendMessageToWs(`api:${payload.id}`, {
error: {
message: e.message,
code: e.code,
id: e.id,
kind: e.kind,
...(e.info ? { info: e.info } : {})
}
});
});
}

Expand Down

0 comments on commit cca3a72

Please sign in to comment.