Checks if a certain type of exception has occurred.
Example: flag = exception_matches(KeyError) Returns .false. if no exception has occurred.