Use error class in registration and similar things

Signed-off-by: emanuele <emanuele45@gmail.com>
Merge pull request #760 from emanuele45/reg_errors

Use error class in registration and similar things