generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/render errors in modal #57
Merged
0x4007
merged 16 commits into
ubiquity:development
from
0x4007:feat/render-errors-in-modal
Jun 6, 2024
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
63c843a
feat: add error icon in modal header
0x4007 fcc3c32
chore: rounded error icon fits better
0x4007 7459f83
feat: render uncaught errors in modal
0x4007 a4a3689
fix: import showError
0x4007 c05c449
fix: detail around only showing error or link to issue modal icon
0x4007 1fa3d3f
chore: currently testing to catch uncaught errors
0x4007 59b8cc9
refactor: clean up error logic, and tested by throwing error in program
0x4007 26b3121
chore: more manual testing of error displaying
0x4007 45cc922
test: catch missing env vars
0x4007 e5e3511
test: fix env var loader
0x4007 011a412
fix: display caught errors in modal as well
0x4007 b3b274c
chore: formatting
0x4007 1d16140
fix: wrap async event handlers to catch and render errors in modal
0x4007 9243a6e
feat: handle special errors differently for rate limiting and automat…
0x4007 a53c213
style: formatter
0x4007 88eafce
chore: remove commented out code
0x4007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"version": "0.2", | ||
"words": ["devpool", "supabase"] | ||
"words": ["devpool", "ratelimit", "supabase", "UBIQUIBOT"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
SUPABASE_URL= | ||
SUPABASE_ANON_KEY= | ||
SUPABASE_ANON_KEY= | ||
UBIQUIBOT_GITHUB_USERNAME= | ||
UBIQUIBOT_GITHUB_PASSWORD= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { RequestError } from "@octokit/request-error"; | ||
import { Octokit } from "@octokit/rest"; | ||
import { getGitHubUser } from "../getters/get-github-user"; | ||
import { renderErrorInModal } from "../rendering/display-popup-modal"; | ||
import { rateLimitModal } from "./fetch-issues-preview"; | ||
|
||
type RateLimit = { | ||
reset: number | null; | ||
user: boolean; | ||
}; | ||
|
||
export async function handleRateLimit(octokit?: Octokit, error?: RequestError) { | ||
const rate: RateLimit = { | ||
reset: null, | ||
user: false, | ||
}; | ||
|
||
if (error?.response?.headers["x-ratelimit-reset"]) { | ||
rate.reset = parseInt(error.response.headers["x-ratelimit-reset"]); | ||
} | ||
|
||
if (octokit) { | ||
try { | ||
const core = await octokit.rest.rateLimit.get(); | ||
const remaining = core.data.resources.core.remaining; | ||
const reset = core.data.resources.core.reset; | ||
|
||
rate.reset = !rate.reset && remaining === 0 ? reset : rate.reset; | ||
rate.user = (await getGitHubUser()) ? true : false; | ||
} catch (err) { | ||
renderErrorInModal(err as Error, "Error handling GitHub rate limit"); | ||
} | ||
} | ||
|
||
const resetParsed = rate.reset && new Date(rate.reset * 1000).toLocaleTimeString(); | ||
|
||
if (!rate.user) { | ||
rateLimitModal(`You have been rate limited. Please log in to GitHub to increase your GitHub API limits, otherwise you can try again at ${resetParsed}.`); | ||
} else { | ||
rateLimitModal(`You have been rate limited. Please try again at ${resetParsed}.`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized this is unnecessary in its current form.