Error Handling and mapping

Error handling has been added to all the functions (TL, RTL and learn)