Skip to content

Loading…

Update classes/kohana/database/mssql.php #4

Merged
merged 1 commit into from

2 participants

@gorets

Добавляем вывод ошибки в читабельном виде, а не в виде кода

@gorets gorets Update classes/kohana/database/mssql.php
Добавляем вывод ошибки в читабельном виде, а не в виде кода
c2246c2
@xrado xrado merged commit cb2b80e into xrado:3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 14, 2012
  1. @gorets

    Update classes/kohana/database/mssql.php

    gorets committed
    Добавляем вывод ошибки в читабельном виде, а не в виде кода
Showing with 8 additions and 4 deletions.
  1. +8 −4 classes/kohana/database/mssql.php
View
12 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());
}
Something went wrong with that request. Please try again.