mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-22 14:22:33 +01:00
chore: improve error message
This commit is contained in:
parent
66c30891af
commit
6a8da2e6fe
3 changed files with 15 additions and 21 deletions
|
@ -16,15 +16,11 @@ export const getIp = (req: any) => {
|
|||
};
|
||||
|
||||
export const getErrorMsg = (error: any[] | string): string => {
|
||||
if (typeof error === 'string') {
|
||||
return error;
|
||||
}
|
||||
if (error.length >= 2) {
|
||||
return error[1];
|
||||
}
|
||||
// if (error.length > 2) {
|
||||
// return error[2].err?.message || 'Error';
|
||||
// }
|
||||
console.log(error);
|
||||
if (!error) return 'Unknown Error';
|
||||
if (typeof error === 'string') return error;
|
||||
if (error[2]?.err?.details) return error[2]?.err?.details;
|
||||
if (error[1]) return error[1];
|
||||
|
||||
return 'Error';
|
||||
return 'Unkown Error';
|
||||
};
|
||||
|
|
|
@ -8,9 +8,7 @@ import {
|
|||
getPendingChannels,
|
||||
} from 'ln-service';
|
||||
import { ContextType } from 'server/types/apiTypes';
|
||||
import { logger } from 'server/helpers/logger';
|
||||
import { requestLimiter } from 'server/helpers/rateLimiter';
|
||||
import { getErrorMsg } from 'server/helpers/helpers';
|
||||
import { sortBy } from 'underscore';
|
||||
import { to } from 'server/helpers/async';
|
||||
import {
|
||||
|
@ -114,18 +112,15 @@ export const chainResolvers = {
|
|||
|
||||
const format = params.nested ? 'np2wpkh' : 'p2wpkh';
|
||||
|
||||
try {
|
||||
const address = await createChainAddress({
|
||||
const address = await to<{ address: string }>(
|
||||
createChainAddress({
|
||||
lnd,
|
||||
is_unused: true,
|
||||
format,
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
return address.address;
|
||||
} catch (error) {
|
||||
logger.error('Error creating address: %o', error);
|
||||
throw new Error(getErrorMsg(error));
|
||||
}
|
||||
return address.address;
|
||||
},
|
||||
sendToAddress: async (_: undefined, params: any, context: ContextType) => {
|
||||
await requestLimiter(context.ip, 'sendToAddress');
|
||||
|
|
|
@ -55,7 +55,10 @@ export const UtxoCard = ({
|
|||
{renderLine('Confirmations: ', confirmation_count)}
|
||||
{renderLine('Output Script: ', output_script)}
|
||||
{renderLine('Transaction Id: ', getTransactionLink(transaction_id))}
|
||||
{renderLine('Transaction Vout: ', transaction_vout)}
|
||||
{renderLine(
|
||||
'Transaction Vout: ',
|
||||
transaction_vout >= 0 ? `${transaction_vout}` : '-'
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue