Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: formatting
  • Loading branch information
amychisholm03 committed Jul 2, 2024
commit 906c18e5ae23c29ab71a320c8491d7b36fb6ffd8
43 changes: 26 additions & 17 deletions lib/errors/error-collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ class ErrorCollector {

/**
* Gets the iterable property from the transaction based on the error type
*
* @param {Transaction} transaction the collected exception's transaction
* @param {string} errorType the type of error to be processed: "user", "transactionException", "transaction"
* @returns
* @param {string} errorType the type of error: "user", "transactionException", "transaction"
* @returns {Array} the iterable property from the transaction based on the error type
*/
_getIterableProperty(transaction, errorType) {
let iterableProperty = null
Expand All @@ -117,25 +118,33 @@ class ErrorCollector {
*/
_processErrors(transaction, collectedErrors, expectedErrors, errorType) {
const iterableProperty = this._getIterableProperty(transaction, errorType)
if (iterableProperty) {
iterableProperty.forEach((exception) => {
if (this.collect(transaction, exception)) {
++collectedErrors
if (
urltils.isExpectedError(this.config, transaction.statusCode) ||
errorHelper.isExpectedException(transaction, exception, this.config, urltils)
) {
++expectedErrors
}
if (iterableProperty === null && errorType === 'transaction') {
if (this.collect(transaction)) {
collectedErrors++
if (urltils.isExpectedError(this.config, transaction.statusCode)) {
expectedErrors++
}
})
} else if (errorType === 'transaction' && this.collect(transaction)) {
++collectedErrors
if (urltils.isExpectedError(this.config, transaction.statusCode)) {
++expectedErrors
}
return [collectedErrors, expectedErrors]
}

if (iterableProperty === null) {
return [collectedErrors, expectedErrors]
}

for (let i = 0; i < iterableProperty.length; i++) {
const exception = iterableProperty[i]
if (!this.collect(transaction, exception)) {
continue
}
collectedErrors++
if (
urltils.isExpectedError(this.config, transaction.statusCode) ||
errorHelper.isExpectedException(transaction, exception, this.config, urltils)
) {
expectedErrors++
}
}
return [collectedErrors, expectedErrors]
}

Expand Down