Fix: only log errors directly if exist

pull/3016/head
shamoon 10 months ago
parent 68e4b98ddb
commit e92ccc30ba

@ -28,7 +28,7 @@ export default async function handler(req, res) {
res.setHeader("Content-Type", mimeType);
return res.status(200).send(fileContent);
} catch (error) {
logger.error(error);
if (error) logger.error(error);
return res.status(500).end("Internal Server Error");
}
}

@ -80,7 +80,7 @@ export default async function handler(req, res) {
error: "not found",
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
return res.status(500).send({
error: { message: e?.message ?? "Unknown error" },
});

@ -108,7 +108,7 @@ export default async function handler(req, res) {
status: "not found",
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
return res.status(500).send({
error: { message: e?.message ?? "Unknown error" },
});

@ -106,7 +106,7 @@ export default async function handler(req, res) {
stats,
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
res.status(500).send({
error: "unknown error",
});

@ -59,7 +59,7 @@ export default async function handler(req, res) {
status,
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
res.status(500).send({
error: "unknown error",
});

@ -71,8 +71,8 @@ export default async function handler(req, res) {
logger.debug("Unknown proxy service type: %s", type);
return res.status(403).json({ error: "Unkown proxy service type" });
} catch (ex) {
logger.error(ex);
} catch (e) {
if (e) logger.error(e);
return res.status(500).send({ error: "Unexpected error" });
}
}

@ -94,7 +94,7 @@ export default async function handler(req, res) {
nodes: Object.entries(nodeMap).map(([name, node]) => ({ name, ...node })),
});
} catch (e) {
logger.error("exception %s", e);
if (e) logger.error(e);
return res.status(500).send({
error: "unknown error",
});

@ -65,7 +65,7 @@ export async function getStaticProps() {
},
};
} catch (e) {
if (logger) {
if (logger && e) {
logger.error(e);
}
return {

@ -325,7 +325,7 @@ export async function servicesFromKubernetes() {
return mappedServiceGroups;
} catch (e) {
logger.error(e);
if (e) logger.error(e);
throw e;
}
}

@ -44,7 +44,7 @@ function handleRequest(requestor, url, params) {
// zlib errors
responseContent.on("error", (e) => {
logger.error(e);
if (e) logger.error(e);
responseContent = response; // fallback
});
response.pipe(responseContent);
@ -112,7 +112,7 @@ export async function httpProxy(url, params = {}) {
constructedUrl.port ? `:${constructedUrl.port}` : "",
constructedUrl.pathname,
);
logger.error(err);
if (err) logger.error(err);
return [500, "application/json", { error: { message: err?.message ?? "Unknown error", url, rawError: err } }, null];
}
}

@ -63,7 +63,7 @@ export default async function audiobookshelfProxyHandler(req, res) {
return res.status(200).send(libraryStats);
} catch (e) {
logger.error(e.message);
if (e) logger.error(e);
return res.status(500).send({ error: { message: e.message } });
}
}

@ -28,7 +28,7 @@ export default async function gamedigProxyHandler(req, res) {
ping: serverData.ping,
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
res.status(200).send({
online: false,

@ -18,7 +18,7 @@ export default async function minecraftProxyHandler(req, res) {
players: pingResponse.players,
});
} catch (e) {
logger.error(e);
if (e) logger.error(e);
res.status(200).send({
version: undefined,
online: false,

@ -103,7 +103,7 @@ export default async function pyloadProxyHandler(req, res) {
}
}
} catch (e) {
logger.error(e);
if (e) logger.error(e);
return res.status(500).send({ error: { message: `Error communicating with Pyload API: ${e.toString()}` } });
}

Loading…
Cancel
Save