class Alphred::Error
Constants
- ASSETS
Attributes
error[R]
Public Class Methods
new(error)
click to toggle source
# File lib/alphred/error.rb, line 18 def initialize(error) @error = error end
try() { || ... }
click to toggle source
# File lib/alphred/error.rb, line 10 def self.try yield rescue Exception => e print self.new(e).to_json end
Public Instance Methods
backtrace_items()
click to toggle source
# File lib/alphred/error.rb, line 34 def backtrace_items icon = File.join(ASSETS, 'more.png') base_dirs = $LOAD_PATH + [ENV['alfred_preferences']] to_delete = /^#{base_dirs.join(?|)}/ self.error.backtrace.map { |line| title = line.sub(to_delete, '...') Item.new( title: title, subtitle: line, arg: line, icon: icon, ) } end
to_items()
click to toggle source
# File lib/alphred/error.rb, line 26 def to_items icon = File.join(ASSETS, 'close.png') items = [ Alphred::Item.new(title: "#{self.error.class}: #{self.error}", icon: icon) ] items.concat(self.backtrace_items) Items[*items] end
to_json(options=nil)
click to toggle source
# File lib/alphred/error.rb, line 22 def to_json(options=nil) to_items.to_json(options) end