Fixed #24014 -- Unified OGRException and GDALException

Thanks Tim Graham for the review.