Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
dc221dc7
Commit
dc221dc7
authored
Apr 16, 2018
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化了 Server 端的异常机制
parent
ee8b1cbc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
ApiException.php
src/base/ApiException.php
+28
-0
Client.php
src/base/Client.php
+1
-1
Server.php
src/base/Server.php
+1
-1
No files found.
src/base/ApiException.php
View file @
dc221dc7
...
@@ -18,4 +18,32 @@ namespace internalApi\base;
...
@@ -18,4 +18,32 @@ namespace internalApi\base;
*/
*/
class
ApiException
extends
\Exception
class
ApiException
extends
\Exception
{
{
protected
$remote
;
public
function
__construct
(
$message
=
""
,
$code
=
0
,
array
$remote
=
null
,
\Throwable
$previous
=
NULL
)
{
parent
::
__construct
(
$message
,
$code
,
$previous
);
$this
->
remote
=
$remote
;
}
public
function
getRemoteClass
()
{
return
$this
->
remote
[
'class'
];
}
public
function
getRemoteLine
()
{
return
$this
->
remote
[
'line'
];
}
public
function
getRemoteFile
()
{
return
$this
->
remote
[
'file'
];
}
public
function
getRemoteTraceString
()
{
return
$this
->
remote
[
'traceString'
];
}
}
}
\ No newline at end of file
src/base/Client.php
View file @
dc221dc7
...
@@ -125,7 +125,7 @@ class Client
...
@@ -125,7 +125,7 @@ class Client
if
(
$httpCode
==
500
&&
substr
(
$response
,
0
,
10
)
===
'exception:'
)
{
if
(
$httpCode
==
500
&&
substr
(
$response
,
0
,
10
)
===
'exception:'
)
{
$e
=
substr
(
$response
,
10
);
$e
=
substr
(
$response
,
10
);
$e
=
json_decode
(
$e
,
true
);
$e
=
json_decode
(
$e
,
true
);
throw
new
ApiException
(
"
{
$e
[
'class'
]
}
:
{
$e
[
'message'
]
}
"
,
$e
[
'code'
]
);
throw
new
ApiException
(
$e
[
'message'
],
$e
[
'code'
],
$e
);
}
}
if
(
$httpCode
==
0
)
{
if
(
$httpCode
==
0
)
{
...
...
src/base/Server.php
View file @
dc221dc7
...
@@ -118,7 +118,7 @@ class Server
...
@@ -118,7 +118,7 @@ class Server
'class'
=>
get_class
(
$e
),
'class'
=>
get_class
(
$e
),
'code'
=>
$e
->
getCode
(),
'code'
=>
$e
->
getCode
(),
'message'
=>
$e
->
getMessage
(),
'message'
=>
$e
->
getMessage
(),
'line'
=>
$e
->
get
Fil
e
(),
'line'
=>
$e
->
get
Lin
e
(),
'file'
=>
$e
->
getFile
(),
'file'
=>
$e
->
getFile
(),
'traceString'
=>
$e
->
getTraceAsString
()
'traceString'
=>
$e
->
getTraceAsString
()
];
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment