Fix handleApiReturn

This commit is contained in:
Sosthene 2025-08-25 01:12:50 +02:00
parent 33dbf552a6
commit 64775af683

View File

@ -981,6 +981,23 @@ export class Service {
}
public async handleApiReturn(apiReturn: ApiReturn) {
// Check for errors in the returned objects
if (apiReturn.new_tx_to_send && apiReturn.new_tx_to_send.error) {
const error = apiReturn.new_tx_to_send.error;
const errorMessage = typeof error === 'object' && error !== null ?
(error as any).GenericError || JSON.stringify(error) :
String(error);
throw new Error(`Transaction error: ${errorMessage}`);
}
if (apiReturn.commit_to_send && apiReturn.commit_to_send.error) {
const error = apiReturn.commit_to_send.error;
const errorMessage = typeof error === 'object' && error !== null ?
(error as any).GenericError || JSON.stringify(error) :
String(error);
throw new Error(`Commit error: ${errorMessage}`);
}
if (apiReturn.partial_tx) {
try {
const res = wasm.sign_transaction(apiReturn.partial_tx);