lutter/ruby-augeas — pull request #1 by mapleoin (2011-11-03 10:42:42+00:00)
Title: fine grained exceptions

I was annoyed at the fact that most augeas errors passed 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.

This code does the following:

- raises ruby exceptions on error (these are the same as the ones in the C library, they have the same message, but their names were changed to be more suggestive (e.g. ECMDRUN -> CommandExecutionError)

- almost all commands are now declared in the ruby module and passed through a run_command private method which checks for errors and raises them (the corresponding methods from the C bindings file are now private)

- a lot of new unit tests have been added for all the new errors and a few for normal invocation of methods which lacked unit tests before

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.

Thanks!