-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(cli): send telemetry on errors #829
Conversation
f67d2b0
to
1ecd59c
Compare
1ecd59c
to
77015f5
Compare
packages/cdktf-cli/bin/cmds/init.ts
Outdated
@@ -386,17 +393,17 @@ async function fetchRemoteTemplate(templateUrl: string): Promise<Template> { | |||
console.error( | |||
chalkColour`Please supply a valid url (including the protocol) or use one of the built-in templates.` | |||
); | |||
process.exit(1); | |||
return await process.exit(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just read a bit on process.exit in the docs and it seems that we should refrain from using such calls. I have used them myself extensively in the past, but they'll make our error reporting unreliable as errors may not always have been sent completely by the time the process exits.
On another note: This is also why we don't need to await the exit and return is also not needed 😅
Fixes #828 Date: Tue Jul 20 18:15:43 2021 +0200
77015f5
to
3ffe2ab
Compare
3ffe2ab
to
284589b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only two minor things, but good to go then 🚀
@@ -397,8 +398,10 @@ export const determineGoModuleName = async (dir: string): Promise<string> => { | |||
const childdir = path.relative(currentDir, dir).replace(/\\/g, "/"); // replace '\' with '/' for windows paths | |||
return childdir.length > 0 ? `${match[1]}/${childdir}` : match[1]; | |||
} | |||
throw new Error( | |||
`Could not determine the root Go module name. Found ${file} but failed to regex match the module name directive` | |||
throw await Errors.Internal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The await
has no effect as report()
is not awaited in reportPrefixedErrors
@@ -407,7 +410,9 @@ export const determineGoModuleName = async (dir: string): Promise<string> => { | |||
currentDir = path.dirname(currentDir); | |||
} while (currentDir !== previousDir); | |||
|
|||
throw new Error( | |||
`Could not determine the root Go module name. No go.mod found in ${dir} and any parent directories` | |||
throw await Errors.Usage( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above with await
packages/cdktf-cli/lib/errors.ts
Outdated
} | ||
|
||
function reportPrefixedError(type: string) { | ||
return (command: string, message: string, context: Record<string, any>) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make the context
optional? (Sometimes an empty object is passed)
a44f2cc
to
1b2f0db
Compare
7aba0f3
to
bdc22b6
Compare
I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This PR helps us track errors to understand the problems of our user-base better.
I added the Errors object in an adjecent effort of being deliberate about Error types