Adds exception handling