Shouldn't aug_save() set error variables when failing?
While debugging an issue that turned out to be related to https://github.com/dominikh/go-augeas/issues/13, I noticed that aug_save() behaves differently from other functions in that it does not set the fields in aug->error.
augtool tells me to use the errors command to retrieve the errors if save fails. IMO there should be a corresponding error code for API use.
The reason aug_save behaves differently here is that it might encounter many errors - if multiple files have changes, and more than one fails to save, we'd simply run out of place in aug->error to report on that.
If you need details on errors during aug_save, you should match on /augeas/files//error (note the double slash) For a human-readable error, the most important bits of information are probably
- the filename: everything in the path that
aug_matchreturns between/augeas/filesand/error. - human-readable message:
error/message - kind/internal error code: the value of the
errornode
Note that aug_load reports errors on reading files with the same mechanism. If you want to avoid getting fooled by these errors when analyzing the result of aug_save, you need to rm /augeas/files//error before calling aug_save.