Improved error handling

This commit is contained in:
La Programmatrice Verde
2025-08-20 18:22:45 +02:00
parent db9e99cc52
commit 97ebcd4527
4 changed files with 95 additions and 57 deletions

View File

@@ -30,16 +30,22 @@ async function Request() {
}
async function isConnected(hostID) {
const response = await axios.get(
`https://api.netbird.io/api/peers/${hostID}`,
{
headers: {
Accept: "application/json",
Authorization: `Token ${shared.getToken()}`,
},
try {
const response = await axios.get(
`https://api.netbird.io/api/peers/${hostID}`,
{
headers: {
Accept: "application/json",
Authorization: `Token ${shared.getToken()}`,
},
}
);
Log(`[${shared.now()}] ${hostID} connected: ${response.data.connected}`);
}
catch (error) {
Log(`[${shared.now()}] ${error}`);
process.exit(3);
}
);
Log(`[${shared.now()}] ${hostID} connected: ${response.data.connected}`);
return response.data.connected;
}
@@ -158,6 +164,7 @@ async function initHostList() {
});
} catch (error) {
Log(`[${shared.now()}] ${error}`);
process.exit(3);
}
}