Permalink
Browse files

Update classes/kohana/database/mssql.php

Добавляем вывод ошибки в читабельном виде, а не в виде кода
  • Loading branch information...
gorets committed Sep 14, 2012
1 parent 345f50b commit c2246c27e325c917bb10fedf2c77def3b4eff0e2
Showing with 8 additions and 4 deletions.
  1. +8 −4 classes/kohana/database/mssql.php
@@ -76,11 +76,15 @@ public function query($type, $sql, $as_object = FALSE, array $params = NULL)
Profiler::delete($benchmark);
}
+ $errArr = $this->_connection->errorInfo();
+ $resultTextError = $this->_connection->query( "select * from sys.messages where language_id=1033 and message_id=".arr::get($errArr, 1, 0) )->fetchAll();
+
// Convert the exception in a database exception
- throw new Database_Exception('[:code] :error ( :query )', array(
- ':code' => $e->getMessage(),
- ':error' => $e->getCode(),
- ':query' => $sql,
+ throw new Database_Exception('[:code] :error ( :info )', array(
+ ':code' => $e->getCode(),
+ ':error' => $e->getMessage(),
+ #':query' => $sql,
+ ':info' => arr::get($resultTextError[0], 'text')
), $e->getCode());
}

0 comments on commit c2246c2

Please sign in to comment.