From a8158c73c88193ddb1ae32013f0e0aec7a411dc2 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 25 Apr 2024 20:25:03 +0100 Subject: [PATCH] add error response handling --- scoresaber-utils.user.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scoresaber-utils.user.js b/scoresaber-utils.user.js index 0d38425..0097ed7 100644 --- a/scoresaber-utils.user.js +++ b/scoresaber-utils.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name ScoreSaber Utils // @namespace https://ssu.fascinated.cc -// @version 1.0.6 +// @version 1.0.7 // @description Useful additions to ScoreSaber! // @author Fascinated // @match https://scoresaber.com/* @@ -20,6 +20,11 @@ */ async function fetchData(url) { const response = await fetch(url); + + if (!response.ok) { + throw new Error(`Failed to fetch data: ${response.status} ${response.statusText}`); + } + return await response.json(); } @@ -84,6 +89,7 @@ async function loadPlayerData(path) { try { const playerData = await fetchData(`https://ssu.fascinated.cc/account/${playerId}`); + addStat( ".stats-container", "+1 PP",