mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
added exception filter and removed controller error handling
This commit is contained in:
@ -2,7 +2,6 @@ import {
|
||||
Body,
|
||||
Controller,
|
||||
Get,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
Post,
|
||||
UseGuards,
|
||||
@ -23,32 +22,21 @@ export class RoleController {
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Get('types')
|
||||
async fetchRoleTypes() {
|
||||
try {
|
||||
const roleTypes = await this.roleService.fetchRoleTypes();
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'Role Types fetched Successfully',
|
||||
data: roleTypes,
|
||||
};
|
||||
} catch (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
const roleTypes = await this.roleService.fetchRoleTypes();
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'Role Types fetched Successfully',
|
||||
data: roleTypes,
|
||||
};
|
||||
}
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(SuperAdminRoleGuard)
|
||||
@Post()
|
||||
async addUserRoleType(@Body() addUserRoleDto: AddUserRoleDto) {
|
||||
try {
|
||||
await this.roleService.addUserRoleType(addUserRoleDto);
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'User Role Added Successfully',
|
||||
};
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Internal server error',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
await this.roleService.addUserRoleType(addUserRoleDto);
|
||||
return {
|
||||
statusCode: HttpStatus.OK,
|
||||
message: 'User Role Added Successfully',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user