Adds exception handling to all functions.