Better error messaging

This commit is contained in:
netop://ウエハ 2019-09-09 17:37:58 -05:00
commit cc965191f2
2 changed files with 10 additions and 7 deletions

View file

@ -64,14 +64,17 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
fetch(`https://api.lbry.com/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`) fetch(`https://api.lbry.com/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`)
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
console.log(result);
switch(true) { switch(true) {
case result.error === "this reward is limited to 1 per person": case result.error === "this reward is limited to 1 per person":
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>"; "<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
return; return;
case result.error:
document.querySelector("developer-program").innerHTML =
`<p>${result.error}</p>`;
return;
case result.success: case result.success:
result = result.data; result = result.data;
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
@ -81,7 +84,7 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
default: default:
console.info(data); // eslint-disable-line no-console console.info(data); // eslint-disable-line no-console
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
"<p><strong>The LBRY API might be down. Please try again later.</strong></p>"; "<p><strong>No success or error was received so the LBRY API might be down.<br/>Please try again later.</strong></p>";
return; return;
} }
}) })

View file

@ -15,11 +15,11 @@ import { generateGitHubFeed } from "~helper/github";
import messageSlack from "~helper/slack"; import messageSlack from "~helper/slack";
import { URL } from "url"; import { URL } from "url";
// const githubAppId = process.env.GITHUB_APP_ID; const githubAppId = process.env.GITHUB_APP_ID;
// const githubAppSecret = process.env.GITHUB_APP_SECRET; const githubAppSecret = process.env.GITHUB_APP_SECRET;
const githubAppId = process.env.GITHUB_APP_ID_TEST; // const githubAppId = process.env.GITHUB_APP_ID_TEST;
const githubAppSecret = process.env.GITHUB_APP_SECRET_TEST; // const githubAppSecret = process.env.GITHUB_APP_SECRET_TEST;