improved session error handling

fixes #1946
This commit is contained in:
Carsten Brandt
2014-03-29 23:54:26 +01:00
parent 8b4d4a0b25
commit c93231e26b
6 changed files with 54 additions and 37 deletions

View File

@@ -8,6 +8,7 @@
namespace yii\mongodb;
use Yii;
use yii\base\ErrorHandler;
use yii\base\InvalidConfigException;
use yii\di\Instance;
@@ -49,6 +50,7 @@ class Session extends \yii\web\Session
*/
public $sessionCollection = 'session';
/**
* Initializes the Session component.
* This method will initialize the [[db]] property to make sure it refers to a valid MongoDB connection.
@@ -148,10 +150,11 @@ class Session extends \yii\web\Session
['upsert' => true]
);
} catch (\Exception $e) {
if (YII_DEBUG) {
echo $e->getMessage();
}
// it is too late to log an error message here
$exception = ErrorHandler::convertExceptionToString($e);
// its too late to use Yii logging here
error_log($exception);
echo $exception;
return false;
}