Hi all,
Is it good programming practice to catch one exception and re-throw it as some other exception type?
Thanks,
Liju Engandiyur
Throw in catch
Moderator: General Moderators
Re: Throw in catch
Not really. The only time I would do that is if I wanted to generalize the exception for something higher up in the chain. Otherwise just let it bubble up the call stack automatically (make sure you don't have a generic catch (Exception $e) then).
For example, the code inside catches a TodayIsNotAThursday exception and you rethrow a DateIsInvalid exception.
For example, the code inside catches a TodayIsNotAThursday exception and you rethrow a DateIsInvalid exception.