fix: catched all errors (#384)

This commit is contained in:
Anurag Hazra 2020-08-13 21:18:26 +05:30 committed by GitHub
parent ec246d27ab
commit 056aaaf189
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 75 deletions

View File

@ -37,9 +37,6 @@ module.exports = async (req, res) => {
parseBoolean(count_private), parseBoolean(count_private),
parseBoolean(include_all_commits) parseBoolean(include_all_commits)
); );
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
const cacheSeconds = clampValue( const cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
@ -49,7 +46,7 @@ module.exports = async (req, res) => {
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`); res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
res.send( return res.send(
renderStatsCard(stats, { renderStatsCard(stats, {
hide: parseArray(hide), hide: parseArray(hide),
show_icons: parseBoolean(show_icons), show_icons: parseBoolean(show_icons),
@ -65,4 +62,7 @@ module.exports = async (req, res) => {
theme, theme,
}) })
); );
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
}; };

View File

@ -27,9 +27,6 @@ module.exports = async (req, res) => {
try { try {
repoData = await fetchRepo(username, repo); repoData = await fetchRepo(username, repo);
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
let cacheSeconds = clampValue( let cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
@ -52,7 +49,7 @@ module.exports = async (req, res) => {
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`); res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
res.send( return res.send(
renderRepoCard(repoData, { renderRepoCard(repoData, {
title_color, title_color,
icon_color, icon_color,
@ -62,4 +59,7 @@ module.exports = async (req, res) => {
show_owner: parseBoolean(show_owner), show_owner: parseBoolean(show_owner),
}) })
); );
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
}; };

View File

@ -29,9 +29,6 @@ module.exports = async (req, res) => {
try { try {
topLangs = await fetchTopLanguages(username); topLangs = await fetchTopLanguages(username);
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
const cacheSeconds = clampValue( const cacheSeconds = clampValue(
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10), parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
@ -41,7 +38,7 @@ module.exports = async (req, res) => {
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`); res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
res.send( return res.send(
renderTopLanguages(topLangs, { renderTopLanguages(topLangs, {
hide_title: parseBoolean(hide_title), hide_title: parseBoolean(hide_title),
hide_border: parseBoolean(hide_border), hide_border: parseBoolean(hide_border),
@ -54,4 +51,7 @@ module.exports = async (req, res) => {
layout, layout,
}) })
); );
} catch (err) {
return res.send(renderError(err.message, err.secondaryMessage));
}
}; };