added error handling mechanism in FFL using the handle_errors() function.