Sean's 4/18 notes: Difference between revisions

From Earlham CS Department
Jump to navigation Jump to search
Sawibel07 (talk | contribs)
Created page with "The errorMessage, jsonError, mesage, and jsonMessage functions print things to standard output and don't log it anywhere. ./util/errors.php, ./util/messages.php Changed errors...."
 
Sawibel07 (talk | contribs)
No edit summary
 
Line 5: Line 5:
Changed errors.php to add a line to print things to the log using Log::getInstance()->log(stuff);
Changed errors.php to add a line to print things to the log using Log::getInstance()->log(stuff);


function errorMessage($msg) {
  function errorMessage($msg) {
  Log::getInstance()->log("$msg");
    Log::getInstance()->log("$msg");
  die($msg);
    die($msg);
}
  }


function jsonError($errorCode, $errorMessage){
  function jsonError($errorCode, $errorMessage){
  Log::getInstance()->log(json_encode(errorResponseCode($errorCode,$errorMessage)));
    Log::getInstance()->log(json_encode(errorResponseCode($errorCode,$errorMessage)));
  echo json_encode(errorResponseCode($errorCode,$errorMessage));
    echo json_encode(errorResponseCode($errorCode,$errorMessage));
  die();
    die();
}
  }

Latest revision as of 18:39, 18 April 2012

The errorMessage, jsonError, mesage, and jsonMessage functions print things to standard output and don't log it anywhere. ./util/errors.php, ./util/messages.php


Changed errors.php to add a line to print things to the log using Log::getInstance()->log(stuff);

 function errorMessage($msg) {
   Log::getInstance()->log("$msg");
   die($msg);
 }
 function jsonError($errorCode, $errorMessage){
   Log::getInstance()->log(json_encode(errorResponseCode($errorCode,$errorMessage)));
   echo json_encode(errorResponseCode($errorCode,$errorMessage));
   die();
 }