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
86b883c1
Commit
86b883c1
authored
Feb 17, 2023
by
谢宇轩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 控制异常范围
parent
5d1dd142
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
13 deletions
+9
-13
Application.php
src/Application.php
+1
-3
ApplicationException.php
src/Exception/ApplicationException.php
+8
-8
Endpoint.temp
template/Endpoint.temp
+0
-2
No files found.
src/Application.php
View file @
86b883c1
...
@@ -107,8 +107,6 @@ class Application implements ClientInterface
...
@@ -107,8 +107,6 @@ class Application implements ClientInterface
* @param RequestInterface $request
* @param RequestInterface $request
* @return ResponseInterface
* @return ResponseInterface
* @throws ApplicationException
* @throws ApplicationException
* @throws GuzzleException
*
*/
*/
public
function
sendRequest
(
RequestInterface
$request
)
:
ResponseInterface
public
function
sendRequest
(
RequestInterface
$request
)
:
ResponseInterface
{
{
...
@@ -173,7 +171,7 @@ class Application implements ClientInterface
...
@@ -173,7 +171,7 @@ class Application implements ClientInterface
$this
->
logger
->
error
(
"sdk etrror, bad client!"
);
$this
->
logger
->
error
(
"sdk etrror, bad client!"
);
}
}
if
(
!
(
$request
instanceof
SdkRequest
))
{
if
(
!
(
$request
instanceof
SdkRequest
))
{
throw
$exception
;
throw
new
ApplicationException
(
$exception
->
getMessage
(),
null
,
[],
$exception
)
;
}
}
throw
new
ApplicationException
(
$exception
->
getMessage
(),
$request
,
[],
$exception
);
throw
new
ApplicationException
(
$exception
->
getMessage
(),
$request
,
[],
$exception
);
}
}
...
...
src/Exception/ApplicationException.php
View file @
86b883c1
...
@@ -13,18 +13,18 @@ class ApplicationException extends ConnectException implements SdkExceptionInter
...
@@ -13,18 +13,18 @@ class ApplicationException extends ConnectException implements SdkExceptionInter
/**
/**
* @param string $message
* @param string $message
* @param SdkRequest $request
* @param SdkRequest
|null
$request
* @param array<string, mixed> $handlerContext
* @param array<string, mixed> $handlerContext
* @param Throwable|null $previous
* @param Throwable|null $previous
*/
*/
public
function
__construct
(
public
function
__construct
(
string
$message
,
string
$message
,
SdkRequest
$request
,
SdkRequest
$request
=
null
,
array
$handlerContext
=
[],
array
$handlerContext
=
[],
?
\Throwable
$previous
=
null
,
?
\Throwable
$previous
=
null
)
{
)
{
$this
->
endpoint
=
$request
->
getEndpoint
();
$this
->
endpoint
=
is_null
(
$request
)
?
""
:
$request
->
getEndpoint
();
$this
->
action
=
$request
->
getAction
();
$this
->
action
=
is_null
(
$request
)
?
""
:
$request
->
getAction
();
parent
::
__construct
(
$message
,
$request
,
$previous
,
$handlerContext
);
parent
::
__construct
(
$message
,
$request
,
$previous
,
$handlerContext
);
}
}
}
}
template/Endpoint.temp
View file @
86b883c1
...
@@ -6,7 +6,6 @@ declare(strict_types=1);
...
@@ -6,7 +6,6 @@ declare(strict_types=1);
namespace
Jiwei
\
{{
Package
}}
\Endpoint
;
namespace
Jiwei
\
{{
Package
}}
\Endpoint
;
use
Closure
;
use
Closure
;
use
GuzzleHttp\Exception\GuzzleException
;
use
Jiwei\EasyHttpSdk\Application
;
use
Jiwei\EasyHttpSdk\Application
;
use
Jiwei\EasyHttpSdk\Exception\SdkException
;
use
Jiwei\EasyHttpSdk\Exception\SdkException
;
use
Jiwei\EasyHttpSdk\Exception\ApplicationException
;
use
Jiwei\EasyHttpSdk\Exception\ApplicationException
;
...
@@ -50,7 +49,6 @@ class {{ Endpoint }}
...
@@ -50,7 +49,6 @@ class {{ Endpoint }}
* @throws ApplicationException
* @throws ApplicationException
* @throws SdkException
* @throws SdkException
* @throws TimeOutExcetpion
* @throws TimeOutExcetpion
* @throws GuzzleException
*/
*/
public
function
{{
item
.
Action
}}({{
item
.
Args
}}
?
Closure
$catch
=
null
,
?
Closure
$then
=
null
)
public
function
{{
item
.
Action
}}({{
item
.
Args
}}
?
Closure
$catch
=
null
,
?
Closure
$then
=
null
)
{
{
...
...
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