Module: Ldaptic::Errors
- Defined in:
- lib/ldaptic/errors.rb
Overview
The module houses all subclasses of Ldaptic::ServerError. The methods contained within are for internal use only.
Defined Under Namespace
Classes: CompareFalse, CompareTrue, NoSuchObject
Constant Summary collapse
- EXCEPTIONS =
{ 32 => NoSuchObject, 5 => CompareFalse, 6 => CompareTrue }
Class Method Summary collapse
-
.application_backtrace ⇒ Object
Provides a backtrace minus all files shipped with Ldaptic.
-
.for(code, message = nil) ⇒ Object
:nodoc:.
-
.raise(exception) ⇒ Object
Raise an exception (object only, no strings or classes) with the backtrace stripped of all Ldaptic files.
-
.raise_unless_zero(code, message = nil) ⇒ Object
Given an error code and a message, raise an Ldaptic::ServerError unless the code is zero.
Class Method Details
.application_backtrace ⇒ Object
Provides a backtrace minus all files shipped with Ldaptic.
103 104 105 106 107 108 |
# File 'lib/ldaptic/errors.rb', line 103 def application_backtrace dir = File.dirname(File.dirname(__FILE__)) c = caller c.shift while c.first[0,dir.length] == dir c end |
.for(code, message = nil) ⇒ Object
:nodoc:
117 118 119 120 121 122 123 |
# File 'lib/ldaptic/errors.rb', line 117 def for(code, = nil) #:nodoc: ||= "Unknown error #{code}" klass = EXCEPTIONS[code] || ServerError exception = klass.new() exception.code = code exception end |
.raise(exception) ⇒ Object
Raise an exception (object only, no strings or classes) with the backtrace stripped of all Ldaptic files.
112 113 114 115 |
# File 'lib/ldaptic/errors.rb', line 112 def raise(exception) exception.set_backtrace(application_backtrace) Kernel.raise exception end |
.raise_unless_zero(code, message = nil) ⇒ Object
Given an error code and a message, raise an Ldaptic::ServerError unless the code is zero. The right subclass is selected automatically if it is available.
128 129 130 |
# File 'lib/ldaptic/errors.rb', line 128 def raise_unless_zero(code, = nil) raise self.for(code, ) unless code.zero? end |