lib/imw/utils/error.rb in imw-0.1.1 vs lib/imw/utils/error.rb in imw-0.2.0
- old
+ new
@@ -1,54 +1,50 @@
-#
-# h2. lib/imw/utils/error -- errors
-#
-# == About
-#
-# Error objects for IMW.
-#
-# Author:: (Philip flip Kromer, Dhruv Bansal) for Infinite Monkeywrench Project (mailto:coders@infochimps.org)
-# Copyright:: Copyright (c) 2008 infochimps.org
-# License:: GPL 3.0
-# Website:: http://infinitemonkeywrench.org/
-#
-
module IMW
- # A generic error class.
- class Error < StandardError
- end
+ # Base error class which all IMW errors subclass.
+ Error = Class.new(StandardError)
- class TypeError < TypeError
- end
+ # Method undefined.
+ NoMethodError = Class.new(Error)
- class ArgumentError < ArgumentError
- end
+ # Type error.
+ TypeError = Class.new(Error)
- class NotImplementedError < NotImplementedError
- end
+ # Not implemented (typically because user needs to define a method
+ # when subclassing a base class).
+ NotImplementedError = Class.new(Error)
- class ParseError < Error
- end
+ # Error during parsing.
+ ParseError = Class.new(Error)
+ # Error with a non-existing, invalid, or inaccessible path.
+ PathError = Class.new(Error)
+
+ # Error communicating with a remote entity.
+ NetworkError = Class.new(Error)
+
+ # Error communicating with a remote entity.
+ ArgumentError = Class.new(Error)
+
# An error meant to be used when a system call goes awry. It will
# report exit status and the process id of the offending call.
class SystemCallError < IMW::Error
- def initialize(message)
+ attr_reader :status, :message
+
+ def initialize(status, message)
+ @status = status
@message = message
end
def display
- "(error code: #{$?.exitstatus}, pid: #{$?.pid}) #{@message}"
+ "(error code: #{status.exitstatus}, pid: #{status.pid}) #{message}"
end
def to_s
- "(error code: #{$?.exitstatus}, pid: #{$?.pid}) #{@message}"
+ "(error code: #{status.exitstatus}, pid: #{status.pid}) #{message}"
end
end
- # A error for improperly specified, inappropriate, or broken paths.
- class PathError < IMW::Error
- end
end