/    Sign up×
Community /Pin to ProfileBookmark

set_exception_handler question

Hello All,

I am using set_exception_handler() so that I can avoid using try/catch blocks so many times in my application. It does what I need except with
set_exception_handler(), the script exits after the method is called.

Is there a way to continue the script rather than having it exit? This way the method sent to set_exception_handler() will do what it needs to and then continue with everything.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMay 10.2009 — Once the function specified by set_exception_handler() completes, processing will end, so anything that you want to have happen after an un-caught exception must somehow be called from within that exception function.

Remember, though: exceptions should be used for truly "exceptional" events, not for expected ("normal"?) errors which should be handeld by normal error-handling (e.g. checking function return values for FALSE or other error indicators and branching the processing accordingly).

An exception should be reserved for indicating that the software was incorrectly written or used incorrectly by the code calling it, it should not be used for handling user errors and such. (Sorry if I'm preaching to the choir here, but I often see exceptions being misused in this way; so if that's not the case here, just ignore me. ? )
×

Success!

Help @ixxalnxxi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...