| Class | Informix::Error |
| In: |
lib/informix/exceptions.rb
|
| Parent: | StandardError |
Informix::Error.new([string|array]) => obj
Optional string is the exception message. Optional array must contain only instances of Informix::ExcInfo structs.
Examples: exc = Informix::Error.new arr = [ExcInfo.new(x,y,z…), ExcInfo.new(a,b,c…)] exc = Informix::Error.new(arr)
# File lib/informix/exceptions.rb, line 71
71: def initialize(v = nil)
72: case v
73: when NilClass
74: @info = []
75: when String
76: @info = []
77: super
78: when Array
79: return @info = v if v.all? {|e| ExcInfo === e}
80: raise(TypeError, "Array may contain only Informix::ExcInfo structs")
81: else
82: raise(TypeError,
83: "Expected string, or array of Informix::ExcInfo, as argument")
84: end
85: end
exc.add_info(sql_code, sql_state, class_origin, subclass_origin,
message, server_name, connection_name) => self
Appends the given information to the exception.
# File lib/informix/exceptions.rb, line 91
91: def add_info(*v)
92: v.flatten!
93: raise(ArgumentError,
94: "Invalid number of arguments (got %d, need %d)", v.size, 7) \
95: if v.size != 7
96: @info.push ExcInfo.new(*v)
97: end
exc.each {|exc_info| block } => exc_info
Calls block once for each Informix::ExcInfo object in the exception.
# File lib/informix/exceptions.rb, line 111
111: def each(&block)
112: @info.each(&block)
113: end