Code Monkey home page Code Monkey logo

stack_rescue's Introduction

StackRescue

A gem for Rails to automatically search Google for exceptions raised in your Rails applications.

After installing, you should see output like this in your Rails logs. This doesn't interfere with better_errors either!

stack_rescue

Installation

Add this line to your application's Gemfile:

gem 'stack_rescue', group: :development

And then execute:

$ bundle

Or install it yourself as:

$ gem install stack_rescue

Usage

By default, search results are limited to 5 results and only from stackoverflow.com.

If you need to modify either of these, add the following to your config/environments/development.rb file:

  # Get results from any website
  config.stack_rescue.site = nil

  # Get results from only stackoverflow.com (default)
  # config.stack_rescue.site = "stackoverflow.com"

  # Change the number of results returned
  # config.stack_rescue.number_of_results = 3

Contributing

  1. Fork it ( https://github.com/excid3/stack_rescue/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

TODO

  • Use number_of_results option to request more pages of results at query time
  • All around usability improvements
  • It would be nice to have these results print after the stacktrace

stack_rescue's People

Contributors

excid3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

stack_rescue's Issues

Rescue when internet connection isn't available

Currently, if you trigger an error in development and you aren't connected to the Internet, the top error in the stack trace (and on the page if you're in the browser) is a SocketError rather than the actual exception that caused the problem. This behavior makes the gem very hard to use if you ever do any offline development, as it obfuscates what the real exception is.

Rescuing should just require 3 lines wrapping the #results method here: https://github.com/excid3/stack_rescue/blob/master/lib/stack_rescue/action_controller.rb#L15 looking something like this:

def results
  search = Google::Search::Web.new :query => query
  search.response.first(number_of_results)

rescue SocketError
  []
end

You could also have the rescue method return an array with a placeholder indicating that StackOverflow was unreachable.

Since you haven't picked a test framework yet, I didn't want to presume whether you are planning to use MiniTest or RSpec here.

Seeing deprecation warning

I was seeing the following deprecation warning upon starting my development server

DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.

Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.

Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.

Commenting out stack_rescue in the development group solved this. There is a rails issue that discusses this problem and the fact it can be caused by older gems.

Other exception sources

It'd be cool if it could go via a Rack middleware to get at exception text. That way it'd work on any rack-based application, e.g. Sinatra

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.