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}`)
.then(response => response.json())
.then(result => {
console.log(result);
switch(true) {
case result.error === "this reward is limited to 1 per person":
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>";
return;
case result.error:
document.querySelector("developer-program").innerHTML =
`<p>${result.error}</p>`;
return;
case result.success:
result = result.data;
document.querySelector("developer-program").innerHTML =
@ -81,7 +84,7 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
default:
console.info(data); // eslint-disable-line no-console
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;
}
})

View file

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