mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-23 06:35:05 +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 => {
|
export const getErrorMsg = (error: any[] | string): string => {
|
||||||
if (typeof error === 'string') {
|
console.log(error);
|
||||||
return error;
|
if (!error) return 'Unknown Error';
|
||||||
}
|
if (typeof error === 'string') return error;
|
||||||
if (error.length >= 2) {
|
if (error[2]?.err?.details) return error[2]?.err?.details;
|
||||||
return error[1];
|
if (error[1]) return error[1];
|
||||||
}
|
|
||||||
// if (error.length > 2) {
|
|
||||||
// return error[2].err?.message || 'Error';
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 'Error';
|
return 'Unkown Error';
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,9 +8,7 @@ import {
|
||||||
getPendingChannels,
|
getPendingChannels,
|
||||||
} from 'ln-service';
|
} from 'ln-service';
|
||||||
import { ContextType } from 'server/types/apiTypes';
|
import { ContextType } from 'server/types/apiTypes';
|
||||||
import { logger } from 'server/helpers/logger';
|
|
||||||
import { requestLimiter } from 'server/helpers/rateLimiter';
|
import { requestLimiter } from 'server/helpers/rateLimiter';
|
||||||
import { getErrorMsg } from 'server/helpers/helpers';
|
|
||||||
import { sortBy } from 'underscore';
|
import { sortBy } from 'underscore';
|
||||||
import { to } from 'server/helpers/async';
|
import { to } from 'server/helpers/async';
|
||||||
import {
|
import {
|
||||||
|
@ -114,18 +112,15 @@ export const chainResolvers = {
|
||||||
|
|
||||||
const format = params.nested ? 'np2wpkh' : 'p2wpkh';
|
const format = params.nested ? 'np2wpkh' : 'p2wpkh';
|
||||||
|
|
||||||
try {
|
const address = await to<{ address: string }>(
|
||||||
const address = await createChainAddress({
|
createChainAddress({
|
||||||
lnd,
|
lnd,
|
||||||
is_unused: true,
|
is_unused: true,
|
||||||
format,
|
format,
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
|
||||||
return address.address;
|
return address.address;
|
||||||
} catch (error) {
|
|
||||||
logger.error('Error creating address: %o', error);
|
|
||||||
throw new Error(getErrorMsg(error));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
sendToAddress: async (_: undefined, params: any, context: ContextType) => {
|
sendToAddress: async (_: undefined, params: any, context: ContextType) => {
|
||||||
await requestLimiter(context.ip, 'sendToAddress');
|
await requestLimiter(context.ip, 'sendToAddress');
|
||||||
|
|
|
@ -55,7 +55,10 @@ export const UtxoCard = ({
|
||||||
{renderLine('Confirmations: ', confirmation_count)}
|
{renderLine('Confirmations: ', confirmation_count)}
|
||||||
{renderLine('Output Script: ', output_script)}
|
{renderLine('Output Script: ', output_script)}
|
||||||
{renderLine('Transaction Id: ', getTransactionLink(transaction_id))}
|
{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