Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
457718cc
Commit
457718cc
authored
Mar 26, 2019
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
token error 修改
parent
47663fc8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
performance/Performance.Api/Filters/ExceptionsFilter.cs
+5
-0
performance/Performance.Api/Util/ClaimService.cs
+2
-2
performance/Performance.DtoModels/Exceptions/PerformanceException.cs
+0
-0
performance/Performance.DtoModels/Exceptions/PerformanceTokenErrorException.cs
+27
-0
No files found.
performance/Performance.Api/Filters/ExceptionsFilter.cs
View file @
457718cc
...
@@ -25,6 +25,11 @@ public Task OnExceptionAsync(ExceptionContext context)
...
@@ -25,6 +25,11 @@ public Task OnExceptionAsync(ExceptionContext context)
_logger
.
LogWarning
(
$"接口错误警告:
{
context
.
Exception
.
ToString
()}
"
);
_logger
.
LogWarning
(
$"接口错误警告:
{
context
.
Exception
.
ToString
()}
"
);
context
.
Result
=
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
context
.
Exception
.
Message
));
context
.
Result
=
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
Fail
,
context
.
Exception
.
Message
));
}
}
else
if
(
context
.
Exception
is
PerformanceTokenErrorException
)
{
_logger
.
LogWarning
(
$"Token Error:
{
context
.
Exception
.
ToString
()}
"
);
context
.
Result
=
new
ObjectResult
(
new
ApiResponse
(
ResponseType
.
TokenError
,
context
.
Exception
.
Message
));
}
else
else
{
{
_logger
.
LogError
(
$"接口异常:
{
context
.
Exception
.
ToString
()}
"
);
_logger
.
LogError
(
$"接口异常:
{
context
.
Exception
.
ToString
()}
"
);
...
...
performance/Performance.Api/Util/ClaimService.cs
View file @
457718cc
...
@@ -23,10 +23,10 @@ public UserIdentity At(ApiRequest request)
...
@@ -23,10 +23,10 @@ public UserIdentity At(ApiRequest request)
public
UserIdentity
At
(
string
token
)
public
UserIdentity
At
(
string
token
)
{
{
if
(
string
.
IsNullOrEmpty
(
token
))
if
(
string
.
IsNullOrEmpty
(
token
))
throw
new
PerformanceException
(
"token is not null"
);
throw
new
Performance
TokenError
Exception
(
"token is not null"
);
var
user
=
_memoryCache
.
Get
<
UserIdentity
>(
token
);
var
user
=
_memoryCache
.
Get
<
UserIdentity
>(
token
);
if
(
user
==
null
)
if
(
user
==
null
)
throw
new
PerformanceException
(
"当前用户未登录"
);
throw
new
Performance
TokenError
Exception
(
"当前用户未登录"
);
return
user
;
return
user
;
}
}
}
}
...
...
performance/Performance.DtoModels/PerformanceException.cs
→
performance/Performance.DtoModels/
Exceptions/
PerformanceException.cs
View file @
457718cc
File moved
performance/Performance.DtoModels/Exceptions/PerformanceTokenErrorException.cs
0 → 100644
View file @
457718cc
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Runtime.Serialization
;
using
System.Threading.Tasks
;
namespace
Performance.DtoModels
{
public
class
PerformanceTokenErrorException
:
Exception
{
public
PerformanceTokenErrorException
()
{
}
public
PerformanceTokenErrorException
(
string
message
)
:
base
(
message
)
{
}
public
PerformanceTokenErrorException
(
string
message
,
Exception
innerException
)
:
base
(
message
,
innerException
)
{
}
protected
PerformanceTokenErrorException
(
SerializationInfo
info
,
StreamingContext
context
)
:
base
(
info
,
context
)
{
}
}
}
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