Extract error class to separate file
Extract exception handling