Add error handling to loader and its usage in process handler