ErrorCase.class.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /* PHP SDK
  3. * @version 2.0.0
  4. * @author connect@qq.com
  5. * @copyright © 2013, Tencent Corporation. All rights reserved.
  6. */
  7. require_once(CLASS_PATH."Recorder.class.php");
  8. /*
  9. * @brief ErrorCase类,封闭异常
  10. * */
  11. class ErrorCase{
  12. private $errorMsg;
  13. public function __construct(){
  14. $this->errorMsg = array(
  15. "20001" => "<h2>配置文件损坏或无法读取,请重新执行intall</h2>",
  16. "30001" => "<h2>The state does not match. You may be a victim of CSRF.</h2>",
  17. "50001" => "<h2>可能是服务器无法请求https协议</h2>可能未开启curl支持,请尝试开启curl支持,重启web服务器,如果问题仍未解决,请联系我们"
  18. );
  19. }
  20. /**
  21. * showError
  22. * 显示错误信息
  23. * @param int $code 错误代码
  24. * @param string $description 描述信息(可选)
  25. */
  26. public function showError($code, $description = '$'){
  27. $recorder = new Recorder();
  28. if(! $recorder->readInc("errorReport")){
  29. die();//die quietly
  30. }
  31. echo "<meta charset=\"UTF-8\">";
  32. if($description == "$"){
  33. die($this->errorMsg[$code]);
  34. }else{
  35. echo "<h3>error:</h3>$code";
  36. echo "<h3>msg :</h3>$description";
  37. exit();
  38. }
  39. }
  40. public function showTips($code, $description = '$'){
  41. }
  42. }