Add exception handling capability. Closes #1