Esempio n. 1
0
/**
 * Format any errors coming back to standardize them
 * @param int $errors Error code
 * @param string $params Params passed to error message (if needed)
 * @return array Array with error codes and messages
 */
function formatErrors($errors, $params = null)
{
    if (is_numeric($errors)) {
        $CI =& get_instance();
        $error_codes = $CI->config->item('error_codes');
        if (array_key_exists($errors, $error_codes)) {
            $errno = $errors;
            $message = empty($params) ? $error_codes[$errno] : call_user_func_array("sprintf", array_merge(array($error_codes[$errno]), $params));
        } else {
            $errno = 0;
            $message = 'Unknown Error';
        }
        if ($errors >= 400 & $errors < 600) {
            set_response_code($errors);
        }
        $errors = array($errno => $message);
    }
    return $errors;
}
Esempio n. 2
0
 /**
  * response, manipule une instance de Response::class
  *
  * @param string $template, le message a envoyer
  * @param int $code, le code d'erreur
  * @param string $type, le type mime du contenu
  * @return Response
  */
 function response($template = null, $code = 200, $type = 'text/html')
 {
     if (is_null($template)) {
         return Response::takeInstance();
     }
     set_header('Content-Type', $type);
     set_response_code($code);
     query_response('send', $template);
     return Response::takeInstance();
 }