I'm catching 3 diffferent exceptions and the error is manipulated differently in all of them as below.
except IntegrityError as e: error_objects.append( { "Row Number": index + 1, "Error": parse_integrity_error(e), "data": user_given_data, } ) except ValidationError as e: error_objects.append( { "Row Number": index + 1, "Error": e.detail[0], "data": user_given_data, } ) except Exception as e: error_objects.append( { "Row Number": index + 1, "Error": str(e), "data": user_given_data, } ) Is there a clean/neat/pythonic way to do it?
except Exceptioncase with a later typecheck to figure out how to produce theErrorvalue, but I think it's a lot clearer the way you have it now.