Exception: Svn::Error
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- Svn::Error
- Defined in:
- lib/svn/errors.rb
Constant Summary collapse
- ERROR_CLASSES =
{}
Instance Attribute Summary collapse
-
#c_error ⇒ Object
readonly
Returns the value of attribute c_error.
Class Method Summary collapse
- .add(code, class_or_name) ⇒ Object
-
.check_and_raise(err_ptr) ⇒ Object
checks error and raises an exception for error if necessary.
-
.class_name_for(message) ⇒ Object
used to turn generic messages for unknown errors into class names e.g., “Repository creation failed” => ‘RepositoryCreationFailedError’.
- .get(code) ⇒ Object
-
.return_check ⇒ Object
returns a proc that calls check_and_raise.
- .specific_error_class(c_error) ⇒ Object
Instance Method Summary collapse
-
#initialize(message_or_c_error) ⇒ Error
constructor
A new instance of Error.
Constructor Details
#initialize(message_or_c_error) ⇒ Error
Returns a new instance of Error.
66 67 68 69 70 71 72 73 |
# File 'lib/svn/errors.rb', line 66 def initialize( ) if .is_a? CError super( . ) @c_error = else super( ) end end |
Instance Attribute Details
#c_error ⇒ Object (readonly)
Returns the value of attribute c_error.
64 65 66 |
# File 'lib/svn/errors.rb', line 64 def c_error @c_error end |
Class Method Details
.add(code, class_or_name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/svn/errors.rb', line 31 def add( code, class_or_name ) klass = nil # keep in scope if class_or_name.is_a? Class klass = class_or_name else name = class_or_name begin # fetch an existing error class and save it for the error code klass = Svn.const_get( name ) rescue NameError => err # create the error class and return it $stderr.puts "Creating #{name} for #{code}" if $debug_svn_errors klass = Svn.const_set( name, Class.new( Svn::Error ) ) end end ERROR_CLASSES[code] = klass end |
.check_and_raise(err_ptr) ⇒ Object
checks error and raises an exception for error if necessary
52 53 54 55 |
# File 'lib/svn/errors.rb', line 52 def check_and_raise( err_ptr ) return if err_ptr.null? raise specific_error_class( err_ptr ).new( err_ptr. ) end |
.class_name_for(message) ⇒ Object
used to turn generic messages for unknown errors into class names e.g., “Repository creation failed” => ‘RepositoryCreationFailedError’
14 15 16 |
# File 'lib/svn/errors.rb', line 14 def class_name_for( ) .split(/\s+/).each(&:capitalize!).join + 'Error' end |
.get(code) ⇒ Object
27 28 29 |
# File 'lib/svn/errors.rb', line 27 def get( code ) ERROR_CLASSES[code] end |
.return_check ⇒ Object
returns a proc that calls check_and_raise
58 59 60 |
# File 'lib/svn/errors.rb', line 58 def return_check @@return_check ||= Proc.new { |ptr| Error.check_and_raise( ptr ) } end |
.specific_error_class(c_error) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/svn/errors.rb', line 18 def specific_error_class( c_error ) # if an error class is already set, return it. otherwise, create a new # one from the error's generic message ( get( c_error.code ) || add( c_error.code, class_name_for( c_error. ) ) ) end |