-
Notifications
You must be signed in to change notification settings - Fork 1
CLI always discards the stack on compilation errors #4
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
As ts-framework-cli wraps module resolution in a try/catch with a throw new BaseError, the error stack is discarded in favor of a useless stack that always points to the CLI internals on compilation errors. Errors should always be rethrown, throw new Error inside a catch is an anti-pattern.
ts-framework-cli/lib/BaseCommand.ts
Lines 109 to 112 in 731ef16
| } catch (exception) { | |
| console.error(exception); | |
| throw new BaseError(`Could not load Server instance: "${exception.message}"`); | |
| } |
Error example:
error: Could not load Server instance: "⨯ Unable to compile TypeScript:
api/services/CDTProviderService.ts(43,24): error TS2345: Argument of type 'CDTPhoneCreditFeature' is not assignable to parameter of type 'BaseCustodyFeature'.
Property 'type' is missing in type 'CDTPhoneCreditFeature' but required in type 'BaseCustodyFeature'.
" (stackId: 8f953bb1-a3db-4ce7-b9f4-9c707cec500c) {
"stack": "BaseError: Could not load Server instance: \"⨯ Unable to compile TypeScript:\napi/services/CDTProviderService.ts(43,24): error TS2345: Argument of type 'CDTPhoneCreditFeature' is not assignable to parameter of type 'BaseCustodyFeature'.\n Property 'type' is missing in type 'CDTPhoneCreditFeature' but required in type 'BaseCustodyFeature'.\n\" (stackId: 8f953bb1-a3db-4ce7-b9f4-9c707cec500c)\n at ListenCommand.<anonymous> (/home/rangel/Workspace/nxtep/bitcapital/bitcapital-cards/node_modules/ts-framework-cli/lib/BaseCommand.ts:111:13)\n at Generator.next (<anonymous>)\n at fulfilled (/home/rangel/Workspace/nxtep/bitcapital/bitcapital-cards/node_modules/ts-framework-cli/dist/BaseCommand.js:4:58)\n at process._tickCallback (internal/process/next_tick.js:68:7)\n at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)\n at startup (internal/bootstrap/node.js:266:19)\n at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)",
"stackId": "8f953bb1-a3db-4ce7-b9f4-9c707cec500c",
"originalMessage": "Could not load Server instance: \"⨯ Unable to compile TypeScript:\napi/services/CDTProviderService.ts(43,24): error TS2345: Argument of type 'CDTPhoneCreditFeature' is not assignable to parameter of type 'BaseCustodyFeature'.\n Property 'type' is missing in type 'CDTPhoneCreditFeature' but required in type 'BaseCustodyFeature'.\n\"",
"name": "BaseError",
"details": {}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers