Make exception_handler handle all exception types

Previously exception_handler expected exceptions to have name and code attributes. We now default to 'Internal error' and 500 respectively if these attributes do not exist.