Skip to content

Instantly share code, notes, and snippets.

@causztic
Last active April 2, 2019 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save causztic/21bbd396251f7c16dec81ef67a153f11 to your computer and use it in GitHub Desktop.
Save causztic/21bbd396251f7c16dec81ef67a153f11 to your computer and use it in GitHub Desktop.
Actionable Errors and new Error Page Design for Ruby on Rails

During GSOC 2018 I have proposed and worked on a feature for Ruby on Rails - Actionable Errors. rails/rails#34788

Summary

Currently, errors with a defined flow to fix them have to be done manually (e.g. when there are pending migrations or when credentials are not found.)

With the new ActionableException concern in ActiveSupport, maintainers for various Ruby on Rails libraries with their special error classes will be able to extend this module and provide the appropriate Actions to take, which the user can activate by clicking on a button.

Description

The ActionableException module consists an ActionableException::Action class that handles the actual labelling and running of the exception-fixing mechanism.

The ActionableException API provides a single class method: actionable which expects either a parameter or a block that returns an ActionableException::Action.

Take a look at PendingMigrationError for an example of the implementation.

The ActionableException::Action class consists of two optional methods and one compulsory method, which are label, running_label and run respectively.

Flow

When the actionable button is clicked, a json POST request is sent to the middleware, which is caught by DebugExceptions. It instantiates the exception based on the payload and runs the appropriate steps given by actionable.

Error Page Design

I have also redesigned the error pages by changing the fonts and moving the components around so that less scrolling is required by the users to access the information they need.

Future Work

I tried but was unable to contact my mentor during the last two weeks of the GSOC program so I was unable to finish the project - there was some errors in the PendingMigrationError test that I was unable to solve.

Sources:

https://github.com/causztic/rails/tree/actionable-errors-updated

https://github.com/causztic/rails/tree/update-error-page-design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment