Skip to content

Commit

Permalink
throw in case not 200
Browse files Browse the repository at this point in the history
  • Loading branch information
fabcotech committed Jul 12, 2024
1 parent 7de13f8 commit 72e9fcd
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/binance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ export const placeSellTradeMarket = async (pair: string, balance: number) => {
}
);
if (placeOrderReq.statusCode !== 200) {
s += `order was not placed ${placeOrderReq.statusCode}:\n`;
s += `${await placeOrderReq.body.text()}:\n`;
console.log(s);
return;
console.log(await placeOrderReq.body.text());
throw new Error(`status code not 200 : ${placeOrderReq.statusCode}`);
}
const binanceOrder = await placeOrderReq.body.json();
console.log(binanceOrder);
Expand All @@ -95,7 +93,7 @@ export const placeSellTradeMarket = async (pair: string, balance: number) => {
};

export const getSymbolInfo = async (symbol: string) => {
const exchangeInfo = await request(
const exchangeInfoReq = await request(
`${apiBase}exchangeInfo?symbol=${symbol.toUpperCase()}`,
{
method: 'GET',
Expand All @@ -104,7 +102,11 @@ export const getSymbolInfo = async (symbol: string) => {
},
}
);
return await exchangeInfo.body.json();
if (exchangeInfoReq.statusCode !== 200) {
console.log(await exchangeInfoReq.body.text());
throw new Error(`status code not 200 : ${exchangeInfoReq.statusCode}`);
}
return await exchangeInfoReq.body.json();
};

export const getPriceTicker = async (
Expand Down

0 comments on commit 72e9fcd

Please sign in to comment.