You've already forked tf2wikipricing
fix: handle key pricing failure
This commit is contained in:
@@ -208,7 +208,24 @@ async function inject() {
|
||||
const priceRows: PriceRow[]= [];
|
||||
|
||||
// Get current key price
|
||||
const keyPrice = await fetchKeyPrice(token);
|
||||
let keyPrice: ItemPriceData
|
||||
try {
|
||||
keyPrice = await fetchKeyPrice(token);
|
||||
} catch (error) {
|
||||
logError('Failed to get a key price from prices.tf: ' + error);
|
||||
// Footer row
|
||||
const row = document.createElement("tr");
|
||||
|
||||
const label = document.createElement("td");
|
||||
label.colSpan = 2;
|
||||
label.style.fontSize = "85%";
|
||||
label.style.textAlign = "center";
|
||||
label.innerHTML = `Failed to get prices from prices.tf. Service may be down.`;
|
||||
row.appendChild(label);
|
||||
priceProgressRow.insertAdjacentElement('afterend', row);
|
||||
priceProgressRow.remove();
|
||||
return
|
||||
}
|
||||
|
||||
const currentTime = new Date()
|
||||
|
||||
@@ -404,7 +421,7 @@ async function inject() {
|
||||
label.colSpan = 2;
|
||||
label.style.fontSize = "85%";
|
||||
label.style.textAlign = "center";
|
||||
const updateText = $T("Updated %@.", locale).replace('%@', updateTime.toLocaleString(locale, { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short' }))
|
||||
const updateText = $T("Updated %@", locale).replace('%@', updateTime.toLocaleString(locale, { year: 'numeric', month: 'long', day: 'numeric', hour: '2-digit', minute: '2-digit', timeZoneName: 'short' }))
|
||||
const attributionHeader = $T("Acknowledgements");
|
||||
const pricesAttribution = `<a rel="nofollow" class="external text" href="https://prices.tf">prices.tf</a>`;
|
||||
const exchangeRateAttribution = `<a rel="nofollow" class="external text" href="https://www.exchangerate-api.com">Rates By Exchange Rate API</a>`;
|
||||
|
||||
Reference in New Issue
Block a user