getFirstErrors(); $result = reset($errors); if (is_numeric($result)) { throw new Exception($result, \Yii::t('error', $result)); } else { throw new Exception(1003, $result); } } /** * getConnect * @author: libingke * @return \PhpAmqpLib\Connection\AMQPStreamConnection * @throws Exception */ public function getConnect() { try { return new \PhpAmqpLib\Connection\AMQPStreamConnection( Yii::$app->Amqp->host, Yii::$app->Amqp->port, Yii::$app->Amqp->user, Yii::$app->Amqp->pass, Yii::$app->Amqp->vhost ); } catch (\Exception $e) { throw new Exception(1001, $e->getMessage()); } } }