Sha256: e61a348e29e4a664befa7144f1d63ba880a19c031353a94443df3b16edd78de5

Contents?: true

Size: 452 Bytes

Versions: 3

Compression:

Stored size: 452 Bytes

Contents

# +exit_code+ for shell programming. 
#
# @example
#
#   MyError = Class.new(Exception)
#   MyError.exit_code = 1
#
#   class MyError2 < Exception 
#     @@eixt_code=1 
#   end
#
#   begin
#     ...
#   rescue MyError => e
#     p e.exit_code    -> 1
#  end
class Exception
  class << self
    def exit_code
      @@exit_code 
    end

    def exit_code=(code)
      @@exit_code = code
    end
  end

  def exit_code
    self.class.exit_code
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tagen-2.0.2 lib/tagen/core/exception.rb
tagen-2.0.1 lib/tagen/core/exception.rb
tagen-2.0.0 lib/tagen/core/exception.rb