estately / rets

A pure-ruby library for fetching data from RETS servers
https://github.com/estately/rets
127 stars 94 forks source link

add specific subclasses of InvalidRequest #137

Closed tcrayford closed 9 years ago

tcrayford commented 9 years ago

this adds specific exception classes for most of the rets errors defined in the spec (http://www.reso.org/assets/RETS/Specifications/rets_1_8.pdf, Appendix C).

They subclass InvalidRequest, because that's what we used to throw in these cases, so there's complete backwards compatability.

hfaulds commented 9 years ago

Can we move all of these exceptions our into a separate file?

I feel like we might find a better place to put this oneliner as well:

INVALID_REQUEST_ERROR_MAPPING = Hash[Rets.constants.map {|c| Rets.const_get(c) }.select { |klass| klass.is_a?(Class) && klass < Rets::InvalidRequest }.map {|klass| [klass.const_get('ERROR_CODE'), klass] }]

tcrayford commented 9 years ago

do you want me to move all our exceptions into that file? Or just these exceptions?

tcrayford commented 9 years ago

(was thinking like lib/rets/exceptions.rb). It does feel kinda weird, because these will still have to be at the toplevel namespace, so that class won't define a module Rets::Exceptions or anything, just module Rets…, which might make it a little harder to find those errors for folk new to the codebase.

hfaulds commented 9 years ago

This is backward compatible because of subtyping so I think this is good to go.