mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
refactor(Telemetry): Report error location for non-normative error codes
This commit is contained in:
parent
c563581ac9
commit
07d5b9c19e
@ -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`
|
||||
@ -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' });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user