Fix case sensitivity in rescue of exceptions

As this can differ across platforms.