adapted error handling