Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why if not connect sending «uncaught exception» and script die? #98

Open
Krispian opened this issue Jul 10, 2015 · 2 comments
Open

Why if not connect sending «uncaught exception» and script die? #98

Krispian opened this issue Jul 10, 2015 · 2 comments

Comments

@Krispian
Copy link

Hello! Im use your cool lib but I have a question:
Why in Absrtact class, if not connect to server sending uncaught exception? Why not wrap it in try...catch.. block that script not died?

if (!$this->_hSocket) {
throw new ApnsPHP_Exception(
"Unable to connect to '{$sURL}': {$sError} ({$nError})"
);
}

@Krispian Krispian reopened this Jul 15, 2015
@kongkannika
Copy link

you can use ApnsPHP_Exception to catch the exception

    try {
        $push->connect();
    } catch (ApnsPHP_Exception $e) {
        //log($e->getTraceAsString(), LOG_ERR);
    } catch (Exception $e) {
        //log($e->getTraceAsString(), LOG_ERR);
    }

@kanadgodse
Copy link

Even I'm facing a similar issue. I am using this library in a cron job and if there are any exceptions thrown, then the code just exits! This stalls processing of other items in the loop resulting in same push notifications being sent multiple times cause they all end up getting stuck on the one errornous device token. I will have to now sit and re write all thrown exceptions to have catch statements. At least the library should've had an option to log the exceptions instead of just throwing them without catching them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants