Print error messages for fatal errors

This commit is contained in:
Jenny Tam 2017-10-24 09:22:30 -07:00
parent c55ad3ed9f
commit 63d7a99c91
2 changed files with 6 additions and 7 deletions

View file

@ -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) {
@ -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);

View file

@ -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;
@ -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;
@ -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;
}