Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Introduce CeleryConnectionException #106

Closed
ergonlogic opened this issue May 26, 2017 · 2 comments
Closed

Introduce CeleryConnectionException #106

ergonlogic opened this issue May 26, 2017 · 2 comments

Comments

@ergonlogic
Copy link
Collaborator

If incorrect credentials are used, we receive:

The website encountered an unexpected error. Please try again later.

PhpAmqpLib\Exception\AMQPProtocolConnectionException: ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile. in PhpAmqpLib\Connection\AbstractConnection->connection_close() (line 661 of vendor/php-amqplib/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php).

call_user_func(Array, Object) (Line: 199)
PhpAmqpLib\Channel\AbstractChannel->dispatch('10,50', '', NULL) (Line: 341)
PhpAmqpLib\Channel\AbstractChannel->wait(Array) (Line: 212)
PhpAmqpLib\Connection\AbstractConnection->connect() (Line: 180)
PhpAmqpLib\Connection\AbstractConnection->__construct('incorrect', 'guest', '/', , 'AMQPLAIN', NULL, 'en_US', Object, 0) (Line: 50)
PhpAmqpLib\Connection\AMQPStreamConnection->__construct('localhost', 5672, 'incorrect', 'guest', '/') (Line: 78)
AMQPLibConnector->GetConnectionObject(Array) (Line: 188)
CeleryAbstract::InitializeAMQPConnection(Array) (Line: 170)
CeleryAbstract->BuildConnection(Array) (Line: 125)
CeleryAdvanced->__construct(Array, Array) (Line: 195)
[...]

To catch this exception, we need to do something like:

    use CeleryAdvanced;
    use PhpAmqpLib\Exception\AMQPProtocolConnectionException;

    [...]

    try {
            $queue = new CeleryAdvanced($broker, $backend);
            return $queue;
    }
    catch(AMQPProtocolConnectionException $e) {
            [...]
    }

It'd be more convenient to add a new exception (CeleryConnectionException), as we then wouldn't need to concerns ourselves with the underlying library.

@gjedeer
Copy link
Owner

gjedeer commented May 29, 2017

Makes sense, PR welcome.

@ergonlogic
Copy link
Collaborator Author

See #107

gjedeer added a commit that referenced this issue May 30, 2017
Fixes #106: Introduce CeleryConnectionException
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants