PHP code example of ddvphp / ddv-exception

1. Go to this page and download the library: Download ddvphp/ddv-exception library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ddvphp / ddv-exception example snippets



\DdvPhp\DdvException\Handler::setHandler(function (array $r, $e) {
  var_dump($r);  
});




throw new \DdvPhp\DdvException\Error("测试一个异常", 'TEST_A_EXCEPTION');



class UserError extends \DdvPhp\DdvException\Error
{
  // 魔术方法
  public function __construct( $message = 'Unknown Error' , $errorId = 'UNKNOWN_ERROR' , $code = '400', $errorData = array() )
  {
    parent::__construct( $message , $errorId , $code, $errorData );
  }
}

throw new UserError("测试一个异常", 'TEST_A_EXCEPTION');