Created
December 19, 2019 08:58
-
-
Save love8587/e9f545f992dac4eff1ef77d341204c2a to your computer and use it in GitHub Desktop.
Async / Await > Catch Error stack trace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getSiteMeta: async (ctx: Context, next: Function) => { | |
| try { | |
| const url = ctx.query.url; | |
| const result = await utilsService.getSiteMeta({ url }); | |
| return success(ctx, 200, `get site meta`, result.data); | |
| } catch (err) { | |
| err.stack = `${err.stack} ${new Error().stack}`; | |
| throw err; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getSiteMeta: async (param: { url: string }) => { | |
| if (!param || !param.url) { | |
| throw boom.badRequest(undefined, { param }); | |
| } | |
| try { | |
| const result = await NewsConnector.getSiteMeta(param.url); | |
| return respondSuccess(result); | |
| } catch (err) { | |
| err.stack = `${err.stack} ${new Error().stack}`; | |
| throw respondError(err); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment