php, can exceptions be thrown 2 levels up?

前端 未结 3 1236
滥情空心
滥情空心 2021-01-18 07:19

I know this is a weird on, but in my code, i have development mode errors, and production mode errors. This is the function i have:

private function error($m         


        
3条回答
  •  滥情空心
    2021-01-18 07:35

    Use Multiple catch Blocks use admin table which has field

    Mode    Value 
    0     Production
    1     Debug     
    

    the first catch which matches the exception is executed

    Example

     try {
    
        if (!$bDBConnection && $row['mode'] ==0 ) {
           throw new Produciton_DBException("Problem with Database");
        }
        else
        {
            throw new Debug_DBException("Problem with Database");
        }
    
     }
     catch(Produciton_DBException $e)
     {
    
      // display suitable error messages
     }
     catch(Debug_DBException $ex)
     {
       // Exception falls through until a match is found
     } 
    

提交回复
热议问题