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: throw actual error reason and messages to screen #3090

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Changes from all commits
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
18 changes: 11 additions & 7 deletions src/common/lib/lnurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import axios from "axios";
import lightningPayReq from "bolt11";
import { isLNURLDetailsError } from "~/common/utils/typeHelpers";
import {
LNURLAuthServiceResponse,
LNURLDetails,
LNURLError,
LNURLAuthServiceResponse,
LNURLPaymentInfo,
} from "~/types";

Expand Down Expand Up @@ -97,19 +97,23 @@ const lnurl = {
const lnurlDetails = data;

if (isLNURLDetailsError(lnurlDetails)) {
throw new Error(`LNURL Error: ${lnurlDetails.reason}`);
throw new Error(lnurlDetails.reason);
} else {
lnurlDetails.domain = url.hostname;
lnurlDetails.url = url.toString();
}

return lnurlDetails;
} catch (e) {
throw new Error(
`Connection problem or invalid lnurl / lightning address: ${
e instanceof Error ? e.message : ""
}`
);
let error = "";
if (axios.isAxiosError(e)) {
error =
(e.response?.data as { reason?: string })?.reason || e.message;
} else if (e instanceof Error) {
error = e.message;
}

throw new Error(error);
}
}
},
Expand Down
Loading