Skip to content

Commit

Permalink
Print error messages for fatal errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Oct 24, 2017
1 parent c55ad3e commit 63d7a99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions test/functional/sqlsrv/MsCommon.inc
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function callFunc($conn, $funcName, $funcArgs, $funcValues)
sqlsrv_free_stmt($stmt);
}

function fatalError($errorMsg, $print = false)
function fatalError($errorMsg, $print = true)
{
SetUTF8Data(false);
if ($print) {
Expand All @@ -425,7 +425,6 @@ function printErrors($message = "")
if (strlen($message) > 0) {
echo $message . "\n";
}

$errors = sqlsrv_errors(SQLSRV_ERR_ERRORS);
if (count($errors) == 0) {
$errors = sqlsrv_errors(SQLSRV_ERR_ALL);
Expand Down
10 changes: 5 additions & 5 deletions test/functional/sqlsrv/MsHelper.inc
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,12 @@ function executeQuery($conn, $sql, $conds = null, $values = null)
if ($stmt) {
$r = sqlsrv_execute($stmt);
if (!$r) {
fatalError("executeQuery: failed to execute \'$sql\'!", true);
fatalError("executeQuery: failed to execute \'$sql\'!");
}
}
}
if (!$stmt) {
fatalError("executeQuery: failed to run query \'$sql\'!", true);
fatalError("executeQuery: failed to run query \'$sql\'!");
}

return $stmt;
Expand All @@ -506,12 +506,12 @@ function executeQueryEx($conn, $sql, $options)
if ($stmt) {
$r = sqlsrv_execute($stmt);
if (!$r) {
fatalError("executeQueryEx: failed to execute \'$sql\'!", true);
fatalError("executeQueryEx: failed to execute \'$sql\'!");
}
}
}
if (!$stmt) {
fatalError("executeQueryEx: failed to run query \'$sql\'!", true);
fatalError("executeQueryEx: failed to run query \'$sql\'!");
}

return $stmt;
Expand Down Expand Up @@ -683,7 +683,7 @@ function insertTestRow($conn, $tbname, $index)
$stmt = sqlsrv_query($conn, $insertSql);
}
if (!$stmt || $result === false) {
fatalError("insertTestRow: failed to insert row $index!\n", true);
fatalError("insertTestRow: failed to insert row $index!\n");
}
return $stmt;
}
Expand Down

0 comments on commit 63d7a99

Please sign in to comment.