Skip to content
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

Improved error handling #178

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Improved error handling #178

wants to merge 5 commits into from

Conversation

afischer
Copy link
Member

@afischer afischer commented Jul 8, 2020

Still in progress, but feel free to comment!

Description of Change

  • Adds clearer error messaging for missing environment variables
  • More descriptive 500 errors on frontend in development
  • Errors on empty tree with descriptive message. Note we are unable to tell if drive ID is bad or if the folder is empty, but auth issues will throw elsewhere.
  • Set clientSecret and clientId in dev mode to avoid having to set them in your .env
Todo:
  • Better error for no folders in tree
  • Show root documents in an "uncategorized" folder?

Related Issue

Closes #62, closes #63

Checklist

  • Ran npm run lint and updated code style accordingly
  • npm run test passes
  • PR has a description and all contributors/stakeholder are noted/cc'ed
  • tests are updated and/or added to cover new code
  • relevant documentation is changed and/or added

@afischer afischer added enhancement New feature or request in progress A member of the community is currently working on a fix labels Jul 8, 2020
@isaacwhite isaacwhite self-requested a review November 19, 2020 18:49
@@ -8,6 +8,9 @@
<div class="tagline">
<h1><%- template('error.500.heading') %></h1>
<p><%- template('error.500.message') %></p>
<% if (locals.isDev && locals.err && locals.err.message) { %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Should we include the full trace here, too?

@@ -65,6 +65,7 @@ module.exports = async (err, req, res, next) => {
const inlined = await loadInlineAssets()
res.status(code).render(`errors/${code}`, {
inlineCSS: inlined.css,
isDev: process.env.NODE_ENV === 'development',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -57,6 +59,12 @@ async function handlePage(req, res) {

if (page === 'categories' || page === 'index') {
const tree = await getTree()
if (!tree.children) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This signal is great. It also seems like we could easily make this nonfatal (log, but have the library site be empty) if we wanted.

server/utils.js Outdated
const level = fs.existsSync(customPath) ? 'warn' : 'debug'
log[level](`Failed pulling in custom file ${attemptPath} @ ${customPath}. Error was:`, err)
// with no stacktrace.
const fileExists = fs.existsSync(customPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 This also seems like a useful signal. Let's make sure it merges cleanly with the other open PR for this case, https://github.com/nytimes/library/pull/202/files

@isaacwhite isaacwhite self-assigned this Dec 4, 2020
Copy link
Member

@isaacwhite isaacwhite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These all seem like great usability improvements, thanks for tackling @afischer!

It looks like we have some merge conflicts, once we resolve those I think these will be great additions 👏

Base automatically changed from master to main March 13, 2021 03:00
@afischer afischer assigned afischer and unassigned isaacwhite May 24, 2021
@afischer afischer changed the title [WIP] Improved error handling Improved error handling May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request in progress A member of the community is currently working on a fix
Projects
None yet
2 participants