a special error for when payments fail.

This commit is contained in:
fiatjaf
2021-04-06 14:57:51 -03:00
parent 59aaea47fd
commit 82731dc901
2 changed files with 10 additions and 3 deletions
+7 -2
View File
@@ -29,6 +29,10 @@ from .crud import (
)
class PaymentFailure(Exception):
pass
async def create_invoice(
*,
wallet_id: str,
@@ -162,8 +166,9 @@ async def pay_invoice(
)
await delete_payment(temp_id, conn=conn)
else:
raise Exception(
payment.error_message or "Failed to pay_invoice on backend."
raise PaymentFailure(
payment.error_message
or "Payment failed, but backend didn't give us an error message."
)
return invoice.payment_hash