PHP code example of softdd / apiexception

1. Go to this page and download the library: Download softdd/apiexception 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/ */

    

softdd / apiexception example snippets


$error  = [
    'code'=>110,
     'msg'=>'msg',
     'httpCode'=>400,
     'headers'=>[]
];
throw (new \SoftDD\ApiException\ApiException($error)); 
// 更详细的定义可以用 ($error, $msg='',$detail=[],$previous=null)

[
    'status'=>0,        //0 表示存在异常,正常返回1
    'data'=>[
        'code'=>'code',
        'msg'=>'message',
        'detail'=>[...] //错误的详细信息,存在时下发。
    ]
];