SHARE
TWEET

Untitled

a guest Aug 19th, 2019 199 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * 独自エラー例外処理クラス(child class)
  5.  *
  6.  * @author Hiroyuki Takai <watashitakai@gmail.com>
  7.  * @since 2019/07/
  8.  */
  9.  
  10. namespace news2\common;
  11.  
  12. use framework2\common\ErrorFunc;
  13.  
  14.  
  15. class AppErrorFunc extends ErrorFunc
  16. {
  17.     protected static $_instance;
  18.  
  19.  
  20.     /**
  21.      * 例外エラーキャッチ後のモード別(dbg,production)振り分け処理
  22.      * @param \Throwable $e
  23.      */
  24.     public static function catchAfter(\Throwable $e)
  25.     {
  26.         parent::catchAfter($e);
  27.     }
  28.  
  29.  
  30.     /**
  31.      * production mode 独自振り分け処理
  32.      * @param \Throwable
  33.      */
  34.     protected function funcByCode(\throwable $e)
  35.     {
  36.         if ($e->getCode() === MYVALID) {
  37.             if (get_class($e) === __NAMESPACE__ . '\MyvalidExceptionChild') {
  38.                 self::case_myvalidChild($e);
  39.             }
  40.         }
  41.         try {
  42.             $msg = 'not defined error code set!';
  43.             throw new \DomainException($msg, DOMAIN);
  44.         } catch(\DomainException $e) {
  45.             parent::catchAfter($e);
  46.         }
  47.     }
  48.    
  49.    
  50.     /**
  51.      * MyvalidExceptionChild例外キャッチ後の処理
  52.      * @param MyvalidExceptionChild $e
  53.      */
  54.     private static function case_myvalidChild(MyvalidExceptionChild $e)
  55.     {
  56.         $ret_url = $e->getRetUrl();
  57.         $id_name = $e->getIdName();    
  58.         $dts = [];
  59.         $list = [$e->getMessage(),
  60.              $ret_url,
  61.              ];          
  62.         for ($i=0; $i<count($list); $i++ ) {
  63.             $dts[] = $list[$i];
  64.         }      
  65.  
  66.         parent::display($id_name, $dts);
  67.         exit();
  68.     }
  69. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top