ethanjweiner / visualize-the-web

A geographic visualizer of HTTP requests across long distances, built with Python and Flask
2 stars 1 forks source link

Visual error handler #62

Closed ethanjweiner closed 3 years ago

ethanjweiner commented 3 years ago

Task Title

Task: Visual error handler

Task Description

This Task will...

Steps to error handling:

  1. Catch the backend error -- e.g. improplery formatted URL, request not allowed, no routes found, etc.
  2. In the backend logic, abort with particular status codes
  3. [If the error occurs within the context of a named route] Handle errors server-side: Use Flask's built-in error handler to display errors
  4. [If the error occurs within the context of an AJAX call] Handle errors client-side: Use the .fail() Promise function to trigger a new request to the error page

Epic Parent

Feature: Awesome Feature Title

ethanjweiner commented 3 years ago

Update: I tried to direct all errors to a singular error handler in Flask. The problem with this was that there was no way to asynchronously render a template using the built-in error handler.

Idea: Use the built-in error handler, and render the template. Retrieve that template in the client-side code, and render it.

ethanjweiner commented 3 years ago

Decision: Instead of redirecting a new route to display errors, we will simply render the error in the same page.

  1. Abort the error
  2. Use Flask's error handler to return JSON to the client
  3. Use this error data to display & close a Bootstrap alert with the given error
ethanjweiner commented 3 years ago

Brainstorm what errors might occur:

Abort in the innermost functions first, but then provide a general abort for unforeseen errors