[augeas-devel] ruby-augeas: fine grained exceptions

David Lutterkort lutter at redhat.com
Wed Nov 16 00:28:23 UTC 2011


Hi Ionut,

On Tue, 2011-11-08 at 14:25 +0100, Ionuț Arțăriși wrote:
> I was annoyed at the fact that most augeas errors pass silently, only
> returning an error code, which meant having to check after each command
> if there actually was an error. I think that behaviour is very C-like
> and not very ruby like. Instead I think the user should be prompted
> immediately when an error happened and which kind of error it was.

I agree with that sentiment, and really like your patches - excellent
code, great tests, and overall a great improvement of the bindings.

There's one fly in the ointment: they are not backwards compatible; in
particular, they will cause huge headaches for puppet, since any code
that uses the bindings right now is not prepared to expect exceptions.
In addition, the patches do away with some of the exception-throwing '!'
variants, again breaking backwards compatibility.

At the same time, I _really_ like what the bindings look like with your
changes. To preserve backwards compatibility, how about we rename the
existing Augeas class to AugeasOld or similar.

We then add a new Augeas class, making sure that Augeas::open returns an
instance of AugeasOld, and mention in the docs that Augeas::open is
deprecated. Add a method Augeas::create(opts = {}) that is more Ruby-ish
than open, i.e. lets you write
        
        Augeas::create(:root => "/tmp", :loadpath => "/some/where", :noload => true, :save_mode => :noop)

> There are some issues remaining, mostly around the load and save
> commands which seem to have quite a different policy about errors
> (1. storing them in the augeas tree, 2. returning success when failing
> in case of load), but that should be a different issue.

It would be nice to help with translating matches for /augeas//error
into more Rubyish objects, maybe with a helper call that produces a
struct from the fields stored for each file under /augeas/files

David





More information about the augeas-devel mailing list