Improved error handling
This commit is contained in:
25
hosts.js
25
hosts.js
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user