Skip to content

Commit

Permalink
json stringifies all errors returned from router (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
aristidesstaffieri authored Jan 8, 2024
1 parent 1fba8fd commit 735ec8a
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/route/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export async function initApiServer(
useMercury
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -173,7 +173,7 @@ export async function initApiServer(
useMercury
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ export async function initApiServer(
const { network, pub_key, soroban_url } = request.query;

if (!useMercury) {
reply.code(400).send("Mercury disabled");
reply.code(400).send(JSON.stringify("Mercury disabled"));
}

try {
Expand All @@ -232,7 +232,7 @@ export async function initApiServer(
);
reply.code(200).send(data);
} catch (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
}
},
});
Expand Down Expand Up @@ -271,7 +271,7 @@ export async function initApiServer(
const { contract_id, pub_key, network } = request.body;

if (!useMercury) {
reply.code(400).send("Mercury disabled");
reply.code(400).send(JSON.stringify("Mercury disabled"));
}

const { data, error } = await mercuryClient.tokenSubscription(
Expand All @@ -280,7 +280,7 @@ export async function initApiServer(
network
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -316,15 +316,15 @@ export async function initApiServer(
const { pub_key, network } = request.body;

if (!useMercury) {
reply.code(400).send("Mercury disabled");
reply.code(400).send(JSON.stringify("Mercury disabled"));
}

const { data, error } = await mercuryClient.accountSubscription(
pub_key,
network
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -365,7 +365,7 @@ export async function initApiServer(
const { pub_key, contract_id, network } = request.body;

if (!useMercury) {
reply.code(400).send("Mercury disabled");
reply.code(400).send(JSON.stringify("Mercury disabled"));
}

const { data, error } = await mercuryClient.tokenBalanceSubscription(
Expand All @@ -374,7 +374,7 @@ export async function initApiServer(
network
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -411,7 +411,7 @@ export async function initApiServer(
network_passphrase
);
if (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
} else {
reply.code(200).send(data);
}
Expand Down Expand Up @@ -456,7 +456,7 @@ export async function initApiServer(
);
reply.code(200).send(data);
} catch (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
}
},
});
Expand Down Expand Up @@ -523,7 +523,7 @@ export async function initApiServer(
};
reply.code(200).send(data);
} catch (error) {
reply.code(400).send(error);
reply.code(400).send(JSON.stringify(error));
}
},
});
Expand Down

0 comments on commit 735ec8a

Please sign in to comment.