Skip to content

Commit

Permalink
[Code] hide language server errors (#33082)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedragon authored and zfy0701 committed Mar 13, 2019
1 parent 2d61c7c commit 11ff56c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions x-pack/plugins/code/server/routes/lsp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import { detectLanguage } from '../utils/detect_language';
import { EsClientWithRequest } from '../utils/esclient_with_request';
import { promiseTimeout } from '../utils/timeout';

const LANG_SERVER_ERROR = 'language server error';

export function lspRoute(
server: hapi.Server,
lspService: LspService,
Expand All @@ -53,14 +55,14 @@ export function lspRoute(
log.error(error);
}
return h
.response(error.toJson())
.response({ code: error.code, msg: LANG_SERVER_ERROR })
.type('json')
.code(503); // different code for LS errors and other internal errors.
} else if (error.isBoom) {
return error;
} else {
return h
.response(JSON.stringify(error))
.response('language server error')
.type('json')
.code(500);
}
Expand Down Expand Up @@ -152,14 +154,14 @@ export function lspRoute(
log.error(error);
if (error instanceof ResponseError) {
return h
.response(error.toJson())
.response({ code: error.code, msg: LANG_SERVER_ERROR })
.type('json')
.code(503); // different code for LS errors and other internal errors.
} else if (error.isBoom) {
return error;
} else {
return h
.response(JSON.stringify(error))
.response(LANG_SERVER_ERROR)
.type('json')
.code(500);
}
Expand Down

0 comments on commit 11ff56c

Please sign in to comment.