Skip to content
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

Fix omfg() in HandleErroredBillingBatch #295

Merged
merged 3 commits into from
Jul 6, 2023
Merged

Conversation

Cruikshanks
Copy link
Member

With the changes we made in Better handle errors in Notifiers calls to omfg() should pass the error separately from any data to be included.

Whilst working on the code we spotted an instance we'd overlooked when updating all our omfg() calls.

With the changes we made in [Better handle errors in Notifiers](#273) calls to `omfg()` should pass the error separately from any data to be included.

Whilst working on the code we spotted an instance we'd overlooked when updating all our `omfg()` calls.
@Cruikshanks Cruikshanks added the bug Something isn't working label Jul 6, 2023
@Cruikshanks Cruikshanks self-assigned this Jul 6, 2023
Plus sort a typo we spotted.
Cruikshanks added a commit that referenced this pull request Jul 6, 2023
When working on [Implement SROC invoice reissuing](#256) we had to deal with a situation where we wanted to throw an error that contained details of the records in the current context.

But we were faced with the issue that we knew the error would eventually find it's way to our notifiers. If we include the details in the error message we break Errbit's ability to group instances of an error. But the standard [Error constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error) doesn't support passing in additional values.

To avoid making things complicated for ourselves we did this

```javascript
const error = new Error('Charging Module reissue request failed')
error.billingBatchExternalId = billingBatchExternalId
error.invoiceExternalId = invoiceExternalId

throw error
```

We know both Pino our logger will include these extra properties in its output and Errbit can still do its stuff.

Then when working on [Fix omfg() in HandleErroredBillingBatch](#295) we did a review of all our `omfg()` calls. This led us to find this in `InitiateBillingBatchService`

```javascript
if (liveBillRunExists) {
  throw Error(`Batch already live for region ${regionId}`)
}
```

This is an example of an error message that will block Errbit from grouping these errors. We could fix this by doing what we did in `ReissueInvoiceService`. But it's probably time to add our own custom error that allows us to do it properly.

This change adds the error and applies it where applicable.
@Cruikshanks Cruikshanks marked this pull request as ready for review July 6, 2023 11:35
@Cruikshanks Cruikshanks requested review from Jozzey and StuAA78 July 6, 2023 11:35
@Cruikshanks Cruikshanks merged commit 8960140 into main Jul 6, 2023
@Cruikshanks Cruikshanks deleted the another-pass-of-logging branch July 6, 2023 15:46
Cruikshanks added a commit that referenced this pull request Jul 6, 2023
When working on [Implement SROC invoice reissuing](#256) we had to deal with a situation where we wanted to throw an error that contained details of the records in the current context.

But we were faced with the issue that we knew the error would eventually find its way to our notifiers. If we include the details in the error message we break Errbit's ability to group instances of an error. But the standard [Error constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error) doesn't support passing in additional values.

To avoid making things complicated for ourselves we did this

```javascript
const error = new Error('Charging Module reissue request failed')
error.billingBatchExternalId = billingBatchExternalId
error.invoiceExternalId = invoiceExternalId

throw error
```

We know both Pino our logger will include these extra properties in its output and Errbit can still do its stuff.

Then when working on [Fix omfg() in HandleErroredBillingBatch](#295) we did a review of all our `omfg()` calls. This led us to find this in `InitiateBillingBatchService`

```javascript
if (liveBillRunExists) {
  throw Error(`Batch already live for region ${regionId}`)
}
```

This is an example of an error message that will block Errbit from grouping these errors. We could fix this by doing what we did in `ReissueInvoiceService`. But it's probably time to add our own custom error that allows us to do it properly.

This change adds the error and applies it where applicable.
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.

2 participants