Skip to content

Commit

Permalink
fix(core): remove critical level from CouldNotFindLnPaymentFromHashEr…
Browse files Browse the repository at this point in the history
…ror (#3702)
  • Loading branch information
dolcalmi authored Dec 13, 2023
1 parent 68cd7b5 commit 7c98994
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 8 additions & 4 deletions core/api/src/app/lightning/delete-ln-payments.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { UnknownLightningServiceError } from "@/domain/bitcoin/lightning"
import { ErrorLevel } from "@/domain/shared"
import { CouldNotFindLnPaymentFromHashError } from "@/domain/errors"
import { LndService } from "@/services/lnd"
import { LnPaymentsRepository } from "@/services/mongoose"
import { UnknownLightningServiceError } from "@/domain/bitcoin/lightning"

import {
addAttributesToCurrentSpan,
asyncRunInSpan,
recordExceptionInCurrentSpan,
SemanticAttributes,
} from "@/services/tracing"
import { LndService } from "@/services/lnd"
import { LnPaymentsRepository } from "@/services/mongoose"

export const deleteLnPaymentsBefore = async (
timestamp: Date,
): Promise<true | ApplicationError> => {
const paymentHashesBefore = await listAllPaymentsBefore(timestamp)
const paymentHashesBefore = listAllPaymentsBefore(timestamp)

for await (const paymentHash of paymentHashesBefore) {
if (paymentHash instanceof Error) return paymentHash
Expand Down Expand Up @@ -43,6 +46,7 @@ const checkAndDeletePaymentForHash = async ({
const lnPayment = await LnPaymentsRepository().findByPaymentHash(paymentHash)
if (lnPayment instanceof Error) {
if (lnPayment instanceof CouldNotFindLnPaymentFromHashError) {
recordExceptionInCurrentSpan({ error: lnPayment, level: ErrorLevel.Critical })
// Attempt to get paymentRequest from lnd
const lndService = LndService()
if (lndService instanceof Error) return lndService
Expand Down
4 changes: 1 addition & 3 deletions core/api/src/domain/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ export class NoExpiredLightningPaymentFlowsError extends CouldNotFindError {}
export class CouldNotFindBtcWalletForAccountError extends CouldNotFindError {
level = ErrorLevel.Critical
}
export class CouldNotFindLnPaymentFromHashError extends CouldNotFindError {
level = ErrorLevel.Critical
}
export class CouldNotFindLnPaymentFromHashError extends CouldNotFindError {}

export class CouldNotFindAccountFromIdError extends CouldNotFindError {}
export class CouldNotFindAccountFromUsernameError extends CouldNotFindError {}
Expand Down
2 changes: 1 addition & 1 deletion core/api/src/services/mongoose/ln-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const LnPaymentsRepository = (): ILnPaymentsRepository => {
payment,
{ new: true },
)
if (!result) return new CouldNotFindLnPaymentFromHashError()
if (!result) return new CouldNotFindLnPaymentFromHashError(payment.paymentHash)
return lnPaymentFromRaw(result)
} catch (err) {
return parseRepositoryError(err)
Expand Down

0 comments on commit 7c98994

Please sign in to comment.