diff --git a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts index 3aad65e..b0ce108 100644 --- a/src/ts/@overflow/commons/websocket/WebSocketRPC.ts +++ b/src/ts/@overflow/commons/websocket/WebSocketRPC.ts @@ -1,4 +1,5 @@ import { + ErrorCode, Notification, Request, Response, @@ -30,6 +31,11 @@ enum WebSocketReadyState { CLOSED = 3, } +export interface RuntimeError { + type: string; + data?: any; +} + export default class WebSocketRPC { private url: string; private connStatus: WebSocketStatus; @@ -145,7 +151,14 @@ export default class WebSocketRPC { console.log(result); promise.resolve(result); } else if (null != error) { - promise.reject(error); + if (ErrorCode.E_RUNTIME === error.Code) { + const runTimeError: RuntimeError = { + type: error.Message, + }; + promise.reject(runTimeError); + } else { + console.log(`System error[${error.Code}|${error.Message}|${error.Data}]`); + } } else { console.log('??????'); } diff --git a/src/ts/@overflow/commons/websocket/protocol/ProtocolError.ts b/src/ts/@overflow/commons/websocket/protocol/ProtocolError.ts index 978d709..ea0bf4e 100644 --- a/src/ts/@overflow/commons/websocket/protocol/ProtocolError.ts +++ b/src/ts/@overflow/commons/websocket/protocol/ProtocolError.ts @@ -1,4 +1,5 @@ export const enum ErrorCode { + E_RUNTIME = -33000, E_PARSE = -32700, E_INVALID_REQ = -32600, E_NO_METHOD = -32601, @@ -22,26 +23,30 @@ export class ProtocolError { /** * getID */ - public getCode(): ErrorCode { + public get Code(): ErrorCode { return this.code; } /** * getBody */ - public getMessage(): string { + public get Message(): string { return this.message; } /** * getError */ - public getData(): any { + public get Data(): any { return this.data; } - public static newError(json: string): ProtocolError { - return JSON.parse(json); + public static convert(error: ProtocolError): ProtocolError { + const code = error.code; + if (undefined === code) { + throw new Error(`Error must include Code`); + } + return new ProtocolError(code, error.message, error.data); } } diff --git a/src/ts/@overflow/commons/websocket/protocol/Response.ts b/src/ts/@overflow/commons/websocket/protocol/Response.ts index b812ea1..a162fcc 100644 --- a/src/ts/@overflow/commons/websocket/protocol/Response.ts +++ b/src/ts/@overflow/commons/websocket/protocol/Response.ts @@ -43,7 +43,7 @@ export class Response extends Header { let res = new Response(id); res.Protocol = response.protocol; res.result = response.result; - res.error = response.error; + res.error = ProtocolError.convert(response.error); return res; } diff --git a/src/ts/@overflow/member/react/SignIn.tsx b/src/ts/@overflow/member/react/SignIn.tsx index 390cf00..92f64c8 100644 --- a/src/ts/@overflow/member/react/SignIn.tsx +++ b/src/ts/@overflow/member/react/SignIn.tsx @@ -20,7 +20,7 @@ export function mapDispatchToProps(dispatch: Dispatch, ownProps?: any): Sig return { onSignIn: (signinId: string, signinPw: string) => { // dispatch(signinActions.request(signinId, signinPw)); - dispatch(asyncRequestActions.request('MemberService', 'signin', signinActions.REQUEST, signinId, signinPw)); + dispatch(asyncRequestActions.request('MemberService1', 'signin', signinActions.REQUEST, signinId, signinPw)); }, onRedirectHome: () => { dispatch(routerPush('/'));