Browse Source

avoid throwing the same type of new db exception.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
3b5768b40a
  1. 8
      framework/yii/db/Command.php

8
framework/yii/db/Command.php

@ -278,11 +278,15 @@ class Command extends \yii\base\Component
return $n;
} catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
if ($e instanceof Exception) {
throw $e;
} else {
$message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
$errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
}
}
}
/**
* Executes the SQL statement and returns query result.
@ -411,11 +415,15 @@ class Command extends \yii\base\Component
return $result;
} catch (\Exception $e) {
Yii::endProfile($token, __METHOD__);
if ($e instanceof Exception) {
throw $e;
} else {
$message = $e->getMessage() . "\nThe SQL being executed was: $rawSql";
$errorInfo = $e instanceof \PDOException ? $e->errorInfo : null;
throw new Exception($message, $errorInfo, (int)$e->getCode(), $e);
}
}
}
/**
* Creates an INSERT command.

Loading…
Cancel
Save