Skip to content

Commit

Permalink
refactor(Telemetry): Report error location for non-normative error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed May 19, 2021
1 parent c563581 commit 07d5b9c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/cli/handle-error.js
Expand Up @@ -36,6 +36,8 @@ const writeMessage = (title, message) => {
consoleLog(' ');
};

const isErrorCodeNormative = RegExp.prototype.test.bind(/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)*$/);

module.exports = async (exception, options = {}) => {
if (!isObject(options)) options = {};
// Due to the fact that the handler can be invoked via fallback, we need to support both `serverless`
Expand Down Expand Up @@ -167,7 +169,7 @@ module.exports = async (exception, options = {}) => {
code: exception.code,
};

if (!isUserError || !exception.code) {
if (!isUserError || !exception.code || !isErrorCodeNormative(exception.code)) {
failureReason.location = resolveErrorLocation(exceptionTokens);
}
await storeTelemetryLocally({ ...telemetryPayload, failureReason, outcome: 'failure' });
Expand Down

0 comments on commit 07d5b9c

Please sign in to comment.