Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
Easy Http SDK
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Back End
Easy Http SDK
Commits
7cdf8e78
Commit
7cdf8e78
authored
Feb 23, 2023
by
谢宇轩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 调整默认返回值逻辑的处理范围
parent
07babe89
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
30 deletions
+18
-30
Application.php
src/Application.php
+18
-30
No files found.
src/Application.php
View file @
7cdf8e78
...
...
@@ -238,44 +238,32 @@ class Application implements ClientInterface
if
(
$response
->
getStatusCode
()
>=
500
)
{
if
(
$this
->
logger
)
{
$this
->
logger
->
error
(
"sdk error,
paypal
service fail"
,
$context
);
$this
->
logger
->
error
(
"sdk error,
Upstream
service fail"
,
$context
);
}
throw
new
SdkException
(
"SDK Upstream Failed"
,
$request
,
$response
,
[]);
throw
new
ApplicationException
(
"SDK Upstream Failed"
,
$request
,
[]);
}
if
(
in_array
(
$response
->
getStatusCode
(),
[
404
,
405
]))
{
try
{
$rpcResult
=
$this
->
option
->
handlingPolicy
()
->
process
(
$response
);
}
catch
(
GuiltyResultException
$exception
)
{
// 没有通过预期判定,转化为 SDK Exception
$this
->
lastRequestContext
[
'error_message'
]
=
$exception
->
getMessage
();
$this
->
lastRequestContext
[
'error_detail'
]
=
$exception
->
getOptions
();
// 获取错误的详情
if
(
$this
->
logger
)
{
$this
->
logger
->
error
(
"sdk error, endpoint not found"
,
$c
ontext
);
$this
->
logger
->
warning
(
"Error"
,
$this
->
lastRequestC
ontext
);
}
throw
new
ApplicationException
(
"Api Endpoint Not Found."
,
$request
,
[]);
}
$rpcResult
=
[];
if
(
$response
->
getStatusCode
()
!=
304
)
{
try
{
$rpcResult
=
$this
->
option
->
handlingPolicy
()
->
process
(
$response
);
}
catch
(
GuiltyResultException
$exception
)
{
// 没有通过预期判定,转化为 SDK Exception
$this
->
lastRequestContext
[
'error_message'
]
=
$exception
->
getMessage
();
$this
->
lastRequestContext
[
'error_detail'
]
=
$exception
->
getOptions
();
// 获取错误的详情
if
(
$this
->
logger
)
{
$this
->
logger
->
warning
(
"Error"
,
$this
->
lastRequestContext
);
}
throw
new
SdkException
(
$exception
->
getMessage
(),
$request
,
$response
,
$exception
->
getOptions
());
}
catch
(
UnknowResultException
$exception
)
{
// 无法解析,转化为 Application Exception
// 日志中保留 OUT PUT
$this
->
lastRequestContext
[
'error_message'
]
=
$exception
->
getMessage
();
$this
->
lastRequestContext
[
'error_detail'
]
=
$exception
->
getResult
();
// 获取错误的详情
if
(
$this
->
logger
)
{
$this
->
logger
->
error
(
"sdk error, bad response content."
,
$this
->
lastRequestContext
);
}
throw
new
ApplicationException
(
"Content Format error."
,
$request
,
[]);
throw
new
SdkException
(
$exception
->
getMessage
(),
$request
,
$response
,
$exception
->
getOptions
());
}
catch
(
UnknowResultException
$exception
)
{
// 无法解析,转化为 Application Exception
// 日志中保留 OUT PUT
$this
->
lastRequestContext
[
'error_message'
]
=
$exception
->
getMessage
();
$this
->
lastRequestContext
[
'error_detail'
]
=
$exception
->
getResult
();
// 获取错误的详情
if
(
$this
->
logger
)
{
$this
->
logger
->
error
(
"sdk error, bad response content."
,
$this
->
lastRequestContext
);
}
throw
new
ApplicationException
(
"Content Format error."
,
$request
,
[]);
}
$version
=
$response
->
getHeader
(
'ETag'
);
if
(
!
empty
(
$version
))
{
$rpcResult
=
array_merge
(
$rpcResult
,
[
...
...
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