Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
translation-server
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinmingyuan
translation-server
Commits
63b12533
You need to sign in or sign up before continuing.
Commit
63b12533
authored
Jan 21, 2025
by
mingyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改class-validator错误返回
parent
b630c56f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
api.exception.filter.ts
src/common/filter/api.exception.filter.ts
+6
-1
translate.controller.ts
src/controller/translate/translate.controller.ts
+3
-0
No files found.
src/common/filter/api.exception.filter.ts
View file @
63b12533
...
@@ -35,7 +35,12 @@ export class ApiExceptionsFilter implements ExceptionFilter {
...
@@ -35,7 +35,12 @@ export class ApiExceptionsFilter implements ExceptionFilter {
const
status
=
exception
?.
status
||
exception
?.
statusCode
||
500
;
const
status
=
exception
?.
status
||
exception
?.
statusCode
||
500
;
console
.
error
(
'requestId:'
+
req
.
requestId
);
console
.
error
(
'requestId:'
+
req
.
requestId
);
const
errorMessage
=
exception
?.
response
?.
message
??
exception
.
message
;
let
errorMessage
=
exception
?.
response
?.
message
??
exception
.
message
;
// class-validator 验证错误处理
if
(
errorMessage
instanceof
Array
)
{
errorMessage
=
errorMessage
[
0
];
}
console
.
error
(
console
.
error
(
'errorMessage:'
+
errorMessage
'errorMessage:'
+
errorMessage
...
...
src/controller/translate/translate.controller.ts
View file @
63b12533
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
Query
,
Query
,
Res
,
Res
,
UploadedFile
,
UploadedFile
,
UseFilters
,
UseInterceptors
,
UseInterceptors
,
}
from
'@nestjs/common'
;
}
from
'@nestjs/common'
;
import
{
TranslateService
}
from
'./translate.service'
;
import
{
TranslateService
}
from
'./translate.service'
;
...
@@ -27,9 +28,11 @@ import { TextToSpeechReqDto } from './dto/req/textToSpeechReq.dto';
...
@@ -27,9 +28,11 @@ import { TextToSpeechReqDto } from './dto/req/textToSpeechReq.dto';
import
{
TTS_VOICE_LIST
}
from
'@/common/utils/constants'
;
import
{
TTS_VOICE_LIST
}
from
'@/common/utils/constants'
;
import
{
BadRequestError
}
from
'@/common/exception/badRequest/BadRequestError'
;
import
{
BadRequestError
}
from
'@/common/exception/badRequest/BadRequestError'
;
import
{
config
}
from
'@/config'
;
import
{
config
}
from
'@/config'
;
import
{
ApiExceptionsFilter
}
from
'@/common/filter/api.exception.filter'
;
@
ApiTags
(
'translate'
)
@
ApiTags
(
'translate'
)
@
UseInterceptors
(
ApiResponseInterceptor
)
@
UseInterceptors
(
ApiResponseInterceptor
)
@
UseFilters
(
ApiExceptionsFilter
)
@
Controller
(
'translate'
)
@
Controller
(
'translate'
)
export
class
TranslateController
{
export
class
TranslateController
{
constructor
(
private
readonly
translateService
:
TranslateService
)
{}
constructor
(
private
readonly
translateService
:
TranslateService
)
{}
...
...
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