Module: Rfm::Error

Extended by:
Error
Included in:
Error
Defined in:
lib/rfm/error.rb

Overview

Error is the base for the error hierarchy representing errors returned by Filemaker.

One could raise a FileMakerError by doing:

raise Rfm::Error.getError(102)

It also takes an optional argument to give a more discriptive error message:

err = Rfm::Error.getError(102, 'add description with more detail here')

The above code would return a FieldMissing instance. Your could use this instance to raise that appropriate exception:

raise err

You could access the specific error code by accessing:

err.code

Defined Under Namespace

Classes: ConcurrencyError, DateValidationError, ExistingValidationError, FieldAccessIsDeniedError, FieldCannotBeModifiedError, FieldMissingError, FileError, GeneralError, InvalidFindModeValueError, LayoutMissingError, MaximumCharactersValidationError, MissingError, NoRecordsFoundError, NumberValidationError, RangeValidationError, RecordAccessDeniedError, RecordInUseError, RecordMissingError, RecordModIdDoesNotMatchError, RfmError, ScriptMissingError, SecurityError, SystemError, TableInUseError, TableMissingError, TimeValidationError, UnableToOpenFileError, UniqueValidationError, UnknownError, ValidationCalculationError, ValidationError, ValueListValidationError

Instance Method Summary (collapse)

Instance Method Details

- (Object) build_message(klass, code, message = nil)

:nodoc:



133
134
135
136
137
138
139
# File 'lib/rfm/error.rb', line 133

def build_message(klass, code, message=nil) #:nodoc:
  msg =  ": #{message}"
  msg << " " unless message.nil?
  msg << "(FileMaker Error ##{code})"
  
  "#{klass.to_s.gsub(/Rfm::Error::/, '')} occurred#{msg}"
end

- (Object) find_by_code(code)

:nodoc:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/rfm/error.rb', line 141

def find_by_code(code) #:nodoc:
  case code
  when 0..99 then SystemError
  when 100..199
    if code == 101; RecordMissingError
    elsif code == 102; FieldMissingError
    elsif code == 104; ScriptMissingError
    elsif code == 105; LayoutMissingError
    elsif code == 106; TableMissingError
    else; MissingError; end
  when 203..299
    if code == 200; RecordAccessDeniedError
    elsif code == 201; FieldCannotBeModifiedError
    elsif code == 202; FieldAccessIsDeniedError
    else; SecurityError; end
  when 300..399
    if code == 301; RecordInUseError
    elsif code == 302; TableInUseError
    elsif code == 306; RecordModIdDoesNotMatchError
    else; ConcurrencyError; end
  when 400..499
   if code == 401; NoRecordsFoundError
   else; GeneralError; end
  when 500..599
    if code == 500; DateValidationError
    elsif code == 501; TimeValidationError
    elsif code == 502; NumberValidationError
    elsif code == 503; RangeValidationError
    elsif code == 504; UniqueValidationError
    elsif code == 505; ExistingValidationError
    elsif code == 506; ValueListValidationError
    elsif code == 507; ValidationCalculationError
    elsif code == 508; InvalidFindModeValueError
    elsif code == 511; MaximumCharactersValidationError
    else; ValidationError
    end
  when 800..899
    if code == 802; UnableToOpenFileError
    else; FileError; end
  else
    UnknownError
  end
end

- (Object) getError(code, message = nil)

This method returns the appropriate FileMaker object depending on the error code passed to it. It also accepts an optional message.



126
127
128
129
130
131
# File 'lib/rfm/error.rb', line 126

def getError(code, message=nil)
  klass   = find_by_code(code)
  message = build_message(klass, code, message)
  error   = klass.new(code, message)
  error
end