module BetterErrors
@private
Constants
- POSSIBLE_EDITOR_PRESETS
- VERSION
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
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 134 def self.default_editor POSSIBLE_EDITOR_PRESETS.detect(-> { {} }) { |config| ENV["EDITOR"] =~ config[:sniff] }[:url] || :textmate end
Returns a proc, 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["/some/file", 123] # => txmt://open?url=file:///some/file&line=123
@return [Proc]
# File lib/better_errors.rb, line 64 def self.editor @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` @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 104 def self.editor=(editor) POSSIBLE_EDITOR_PRESETS.each do |config| if config[:symbols].include?(editor) return self.editor = config[:url] end end if editor.is_a? String self.editor = proc { |file, line| editor % { file: URI.encode_www_form_component(file), line: line } } else if editor.respond_to? :call @editor = editor else raise TypeError, "Expected editor to be a valid editor key, a format string or a callable." end 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/charliesome/better_errors/issues
# File lib/better_errors.rb, line 126 def self.use_pry! REPL::PROVIDERS.unshift const: :Pry, impl: "better_errors/repl/pry" end