Catch query exception

This commit is contained in:
James Cole 2017-12-19 05:20:05 +01:00
parent ac04f77d94
commit 79f700c622
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E

View File

@ -27,8 +27,10 @@ use FireflyIII\Models\CurrencyExchangeRate;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Log;
use Request;
/**
@ -84,8 +86,12 @@ class User extends Authenticatable
if (is_array($role)) {
$role = $role['id'];
}
$this->roles()->attach($role);
try {
$this->roles()->attach($role);
} catch (QueryException $e) {
// don't care
Log::info(sprintf('Query exception when giving user a role: %s', $e->getMessage()));
}
}
/**