test try catch avatar profile
This commit is contained in:
parent
5138a01461
commit
1c36e8dac8
1 changed files with 18 additions and 8 deletions
|
|
@ -29,16 +29,26 @@ export class ProfileAvatarController extends Controller {
|
|||
|
||||
@Get("profileId/{id}")
|
||||
async getProfile(@Path() id: string, @Request() req: RequestWithUser) {
|
||||
let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
try {
|
||||
let _workflow = await new permission().Workflow(req, id, "SYS_REGISTRY_OFFICER");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id);
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
return new HttpSuccess(profile);
|
||||
return new HttpSuccess(profile);
|
||||
} catch (error) {
|
||||
console.error("Error in getProfile:", error);
|
||||
|
||||
if (error instanceof HttpError) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
throw new HttpError(HttpStatus.INTERNAL_SERVER_ERROR, "เกิดข้อผิดพลาดภายในระบบ");
|
||||
}
|
||||
}
|
||||
|
||||
@Get("profileId-admin/{id}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue