Skip to content

feat: capture error codes #597

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

Closed
wants to merge 2 commits into from
Closed

feat: capture error codes #597

wants to merge 2 commits into from

Conversation

cristiand391
Copy link
Member

@cristiand391 cristiand391 commented Mar 25, 2024

Exceptions will include error.code if the failure was caused by a system error like a network connection, fs operation failure, etc.

https://nodejs.org/docs/latest/api/errors.html#class-systemerror

I'm adding this specifically to filter network errors by code in telemetry instead of having to compare strings in error messages.

See: https://salesforce-internal.slack.com/archives/G02K6C90RBJ/p1710431639322819

@W-15451832@

Exceptions will include `error.code` if the failure was caused by a
system error like a network connection, fs operation failure, etc.

https://nodejs.org/docs/latest/api/errors.html#class-systemerror

I'm adding this specifically to filter network errors by code in
telemetry instead of having to compare strings in error messages.
@cristiand391 cristiand391 added the bug Something isn't working label Apr 22, 2024
Copy link

git2gus bot commented Apr 22, 2024

This issue has been linked to a new work item: W-15574169

@cristiand391 cristiand391 marked this pull request as draft July 22, 2024 20:46
@cristiand391
Copy link
Member Author

this was fixed by salesforcecli/sf-plugins-core#568

when an thrown error has code set, you can access it in the error.check prop from the error SfCommand throws:

// error in payload for `COMMAND_ERROR`
{
    "name": "Error",
    "message": "he",
    "stack": "Error: he\n    at SfCommandError.from (file:///Users/cdominguez/code/gh/sf/plugin-org/node_modules/@salesforce/sf-plugins-core/lib/SfCommandError.js:39:16)\n    at Hehe.catch (file:///Users/cdominguez/code/gh/sf/plugin-org/node_modules/@salesforce/sf-plugins-core/lib/sfCommand.js:315:47)\n    at Hehe._run (/Users/cdominguez/code/gh/sf/plugin-org/node_modules/@oclif/core/lib/command.js:305:29)\n    at async Config.runCommand (/Users/cdominguez/.nvm/versions/node/v20.10.0/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/config/config.js:424:25)\n    at async run (/Users/cdominguez/.nvm/versions/node/v20.10.0/lib/node_modules/@salesforce/cli/node_modules/@oclif/core/lib/main.js:95:16)\n    at async file:///Users/cdominguez/.nvm/versions/node/v20.10.0/lib/node_modules/@salesforce/cli/bin/run.js:15:1",
    "exitCode": 1,
    "context": "Hehe",
    "cause": {
      "code": "ETIMEDOUT"
    },
    "status": 1,
    "commandName": "Hehe",
    "warnings": [],
    "skipOclifErrorHandling": true,
    "oclif": {
      "exit": 1
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant