feat: connect UI texts, address CRUD, OTP autofocus and profile to backend
This commit is contained in:
1 parent
4e2c8d5cfe
commit
467532713c
82 files changed
+14436
-274
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import { ExceptionFilter, Catch, ArgumentsHost, HttpException } from '@nestjs/common';
|
||||
import { Response } from 'express';
|
||||
|
||||
@Catch(HttpException)
|
||||
export class HttpExceptionFilter implements ExceptionFilter {
|
||||
catch(exception: HttpException, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse<Response>();
|
||||
const status = exception.getStatus();
|
||||
const exceptionResponse: any = exception.getResponse();
|
||||
|
||||
response.status(status).json({
|
||||
success: false,
|
||||
message: typeof exceptionResponse === 'string' ? exceptionResponse : (exceptionResponse.message || 'خطای سرور'),
|
||||
code: exceptionResponse.error || (status === 400 ? 'BAD_REQUEST' : 'ERROR'),
|
||||
details: typeof exceptionResponse === 'object' ? exceptionResponse : {}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user