-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
088a03c
commit 4e1fe79
Showing
6 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { | ||
Injectable, | ||
NestInterceptor, | ||
ExecutionContext, | ||
CallHandler, | ||
} from '@nestjs/common'; | ||
import { Observable, throwError } from 'rxjs'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class TryCatchInterceptor implements NestInterceptor { | ||
intercept(context: ExecutionContext, next: CallHandler): Observable<any> { | ||
return next.handle().pipe( | ||
catchError((error) => { | ||
// Логируйте ошибку или делайте что-то еще с ней здесь | ||
console.error('Error occurred:', error); | ||
// Возвращаем ошибку, если это необходимо | ||
return throwError({ | ||
status: 'ERROR', | ||
error: error.message, | ||
}); | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { IsString, IsNotEmpty, IsArray, ValidateNested } from 'class-validator'; | ||
import { Type } from 'class-transformer'; | ||
|
||
export class SettingDto { | ||
@IsNotEmpty() | ||
id?: number; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
title: string; | ||
|
||
@IsNotEmpty() | ||
required: boolean; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
type: string; | ||
|
||
@IsNotEmpty() | ||
@IsString() | ||
name?: string; | ||
|
||
@IsArray() | ||
@IsNotEmpty() | ||
answers: string[]; | ||
} |