cppcheck refactoring

* unify error handling
* V2: attribute version must be 2; tag 'errors' must exist