Prepare exception handling with Error class