Revert "enable better_errors for development"

This reverts commit c0e20beb55.

Change-Id: Ic8663b4c50ff15e535e3cb27af7a002502314111
Reviewed-on: https://gerrit.instructure.com/94946
Tested-by: Jenkins
Reviewed-by: Cody Cutrer <cody@instructure.com>
Product-Review: Simon Williams <simon@instructure.com>
QA-Review: Simon Williams <simon@instructure.com>
This commit is contained in:
Simon Williams 2016-11-10 13:17:30 -07:00
parent 8590845a7c
commit 6862281ba6
6 changed files with 17 additions and 66 deletions

View File

@ -12,12 +12,11 @@ group :development do
gem 'spring', '>= 1.3.2'
gem 'spring-commands-rspec', '1.0.2'
gem 'better_errors', '~> 2.1.1', require: false
gem 'binding_of_caller', require: false
# Option to DISABLE_RUBY_DEBUGGING is helpful IDE-based debugging.
# The ruby debug gems conflict with the IDE-based debugger gem.
# Set this option in your dev environment to disable.
unless ENV['DISABLE_RUBY_DEBUGGING']
gem 'byebug', '~> 9.0', platform: :mri
end

View File

@ -1076,8 +1076,6 @@ class ApplicationController < ActionController::Base
# analogous to rescue_action_without_handler from ActionPack 2.3
def rescue_exception(exception)
raise if Rails.env.development? && !ENV['DISABLE_BETTER_ERRORS']
ActiveSupport::Deprecation.silence do
message = "\n#{exception.class} (#{exception.message}):\n"
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)

View File

@ -230,12 +230,7 @@ module CanvasRails
end
end
if Rails.env.development? && !ENV['DISABLED_BETTER_ERRORS']
require 'better_errors'
require 'binding_of_caller'
else
config.exceptions_app = ExceptionsApp.new
end
config.exceptions_app = ExceptionsApp.new
config.before_initialize do
config.action_controller.asset_host = Canvas::Cdn.method(:asset_host_for)

View File

@ -21,12 +21,20 @@ environment_configuration(defined?(config) && config) do |config|
cache_store_rb = File.dirname(__FILE__) + "/cache_store.rb"
eval(File.new(cache_store_rb).read, nil, cache_store_rb, 1)
if ENV['REMOTE_DEBUGGING_ENABLED']
require 'byebug/core'
Byebug.start_server('0.0.0.0', 0)
puts "Byebug listening on 0.0.0.0:#{Byebug.actual_port}" # rubocop:disable Rails/Output
byebug_port_file = File.join(Dir.tmpdir, 'byebug.port')
File.write(byebug_port_file, Byebug.actual_port)
# allow debugging only in development environment by default
#
# Option to DISABLE_RUBY_DEBUGGING is helpful IDE-based debugging.
# The ruby debug gems conflict with the IDE-based debugger gem.
# Set this option in your dev environment to disable.
unless ENV['DISABLE_RUBY_DEBUGGING']
require 'byebug'
if ENV['REMOTE_DEBUGGING_ENABLED']
require 'byebug/core'
Byebug.start_server('0.0.0.0', 0)
puts "Byebug listening on 0.0.0.0:#{Byebug.actual_port}" # rubocop:disable Rails/Output
byebug_port_file = File.join(Dir.tmpdir, 'byebug.port')
File.write(byebug_port_file, Byebug.actual_port)
end
end
# Print deprecation notices to the Rails logger

View File

@ -1,25 +0,0 @@
# monkey patch to always allow other ip addresses in development mode
if Rails.env.development? && !ENV['DISABLE_BETTER_ERRORS']
module BetterErrors
class Middleware
def allow_ip?(_)
true
end
end
end
# BETTER_ERRORS_EDITOR
# Specify which app to open files in by setting BETTER_ERRORS_EDITOR to
# any app that responds to `open` url schemes like `txmt://open?url=/Users...`
# Some possible options are: 'emacs', 'mvim', or 'txmt'. Defaults to txmt.
# If you want to use Sublime, see https://github.com/dhoulb/subl
#
# BETTER_ERRORS_LOCAL_PATH
# If you are using Docker, you will also need to set BETTER_ERRORS_LOCAL_PATH
# to point to the absolute path to canvas on your local machine,
# like '/Users/<username>/Documents/canvas-lms', since it only knows the docker path.
BetterErrors.editor = proc { |file, line|
file = file.sub('/usr/src/app', ENV['BETTER_ERRORS_LOCAL_PATH']) if ENV['BETTER_ERRORS_LOCAL_PATH']
"#{ENV['BETTER_ERRORS_EDITOR' || 'txmt']}://open?url=#{URI.encode_www_form_component file}&line=#{line}"
}
end

View File

@ -239,30 +239,6 @@ Ctrl-C your `docker-compose up` window and restart.
## Debugging
### Better Errors
>[Better Errors](https://github.com/charliesome/better_errors) replaces the standard Rails error page
>with a much better and more useful error page.
A major downside of using byebug in docker is the need to establish a
remote byebug session as this will slow down the booting ruby process.
With Better Errors, a REPL is embedded on the page at the point where an
error was raised. With this approach, you can drop a `raise` or `throw`
where ever you'd like to invoke better errors REPL.
Better Errors also provides helpful links to open the offending file in your
editor of choice. In order to help it find your files on your local machine
(outside the Docker VM), you need to set `BETTER_ERRORS_LOCAL_PATH` in your
`docker-compose.override.yml` file in your app's root directory to be the
absolute path to your app, like `'/Users/<username>/Documents/canvas-lms'`
You can also configure which editor is opened. By default, Better Errors will
try to use TextMate, but you can use any app that supports the `open` url
scheme (like `txmt://open?url=/Users...`). To do so, set `BETTER_ERRORS_EDITOR`
in your `docker-compose.override.yml` to your desired editor. Some possible
options are `emacs`, `mvim`, or `txmt`. If you want to use Sublime, see
https://github.com/dhoulb/subl
### Byebug
A byebug server is running in development mode on the web and job containers