module BetterErrors
@private
Constants
- VERSION
This is changed by CI before building a gem for release, but is not committed.
Attributes
The path to the root of the application. Better Errors uses this property to determine if a file in a backtrace should be considered an application frame. If you are using Better Errors with Rails, you do not need to set this attribute manually.
@return [String]
@private
@private
List of classes that are excluded from inspection. @return [Array]
The ignored instance variables. @return [Array]
The logger to use when logging exception details and backtraces. If you are using Better Errors with Rails, you do not need to set this attribute manually. If this attribute is ‘nil`, nothing will be logged.
@return [Logger, nil]
The maximum variable payload size. If variable.inspect exceeds this, the variable won’t be returned. @return int
Public Class Methods
Automatically sniffs a default editor preset based on the EDITOR environment variable.
@return [Symbol]
# File lib/better_errors.rb, line 131 def self.default_editor Editor.default_editor end
Returns an object which responds to url, which when called with a filename and line number argument, returns a URL to open the filename and line in the selected editor.
Generates TextMate URLs by default.
BetterErrors.editor.url("/some/file", 123) # => txmt://open?url=file:///some/file&line=123
@return [Proc]
# File lib/better_errors.rb, line 65 def self.editor @editor ||= default_editor end
Configures how Better Errors generates open-in-editor URLs.
@overload BetterErrors.editor=(sym)
Uses one of the preset editor configurations. Valid symbols are: * `:textmate`, `:txmt`, `:tm` * `:sublime`, `:subl`, `:st` * `:macvim` * `:atom` @param [Symbol] sym
@overload BetterErrors.editor=(str)
Uses `str` as the format string for generating open-in-editor URLs. Use `%{file}` and `%{line}` as placeholders for the actual values. @example BetterErrors.editor = "my-editor://open?url=%{file}&line=%{line}" @param [String] str
@overload BetterErrors.editor=(proc)
Uses `proc` to generate open-in-editor URLs. The proc will be called with `file` and `line` parameters when a URL needs to be generated. Your proc should take care to escape `file` appropriately with `URI.encode_www_form_component` (please note that `URI.escape` is **not** a suitable substitute.) @example BetterErrors.editor = proc { |file, line| "my-editor://open?url=#{URI.encode_www_form_component file}&line=#{line}" } @param [Proc] proc
# File lib/better_errors.rb, line 106 def self.editor=(editor) if editor.is_a? Symbol @editor = Editor.editor_from_symbol(editor) raise(ArgumentError, "Symbol #{editor} is not a symbol in the list of supported errors.") unless editor elsif editor.is_a? String @editor = Editor.for_formatting_string(editor) elsif editor.respond_to? :call @editor = Editor.for_proc(editor) else raise ArgumentError, "Expected editor to be a valid editor key, a format string or a callable." end end
Enables experimental Pry support in the inline REPL
If you encounter problems while using Pry, please file a bug report at github.com/BetterErrors/better_errors/issues
# File lib/better_errors.rb, line 123 def self.use_pry! REPL::PROVIDERS.unshift const: :Pry, impl: "better_errors/repl/pry" end