Skip to content

Commit

Permalink
✔ Handle Error Info ~
Browse files Browse the repository at this point in the history
  • Loading branch information
bifeldy committed Apr 30, 2023
1 parent 1f4f96c commit b3a154c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 15 deletions.
53 changes: 40 additions & 13 deletions src/api/controllers/fansub-/fansub-dns.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ export class FansubDnsController {
if (dns_id_alt_delete && dns_id_alt_delete.status >= 200 && dns_id_alt_delete.status < 400) {
fansub.dns_id_alt = null;
fansub = await this.fansubRepo.save(fansub);
} else {
throw new HttpException({
info: `💩 ${dns_id_alt_delete?.status || 500} - Cloudflare API :: Gagal Menambah / Memperbaharui Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
}
}, dns_id_alt_delete?.status || HttpStatus.INTERNAL_SERVER_ERROR);
}
}
let isUpdateMode = false;
Expand All @@ -65,8 +72,22 @@ export class FansubDnsController {
if (dns_id_delete && dns_id_delete.status >= 200 && dns_id_delete.status < 400) {
fansub.dns_id = null;
fansub = await this.fansubRepo.save(fansub);
} else {
throw new HttpException({
info: `💩 ${dns_id_delete?.status || 500} - Cloudflare API :: Gagal Menambah / Memperbaharui Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
}
}, dns_id_delete?.status || HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} else {
throw new HttpException({
info: `💩 ${dns_id_detail?.status || 500} - Cloudflare API :: Gagal Mengambil Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
}
}, dns_id_detail?.status || HttpStatus.INTERNAL_SERVER_ERROR);
}
}
let dns_id = null;
Expand Down Expand Up @@ -113,11 +134,11 @@ export class FansubDnsController {
};
} else {
throw new HttpException({
info: `💩 500 - Cloudflare API :: Gagal Memperbaharui Data 🤬`,
info: `💩 ${dns_id_alt?.status || 400} - Cloudflare API :: Gagal Menambah / Memperbaharui Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
message: 'Data Tidak Lengkap!'
}
}, HttpStatus.INTERNAL_SERVER_ERROR);
}, dns_id_alt?.status || HttpStatus.BAD_REQUEST);
}
}
}
Expand All @@ -144,11 +165,11 @@ export class FansubDnsController {
delete fansub.user_;
} else {
throw new HttpException({
info: `💩 500 - Cloudflare API :: Gagal Memperbaharui Data 🤬`,
info: `💩 ${dns_id?.status || 400} - Cloudflare API :: Gagal Menambah / Memperbaharui Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
message: 'Data Tidak Lengkap!'
}
}, HttpStatus.INTERNAL_SERVER_ERROR);
}, dns_id?.status || HttpStatus.BAD_REQUEST);
}
return { result, fansub };
}
Expand Down Expand Up @@ -363,6 +384,13 @@ export class FansubDnsController {
created_at: dns_id.result.created_on,
updated_at: dns_id.result.modified_on
};
} else {
throw new HttpException({
info: `💩 ${dns_id?.status || 404} - Cloudflare API :: Gagal Mengambil Data 🤬`,
result: {
message: 'Gagal Terhubung Dengan DNS Server!'
}
}, dns_id?.status || HttpStatus.NOT_FOUND);
}
if (group.fansub_.dns_id_alt) {
const dns_id_alt = await this.cfs.detailDns(group.fansub_.dns_id_alt);
Expand All @@ -377,15 +405,14 @@ export class FansubDnsController {
created_at: dns_id_alt.result.created_on,
updated_at: dns_id_alt.result.modified_on
};
} else {
// Not Required
}
}
if (result.dns_id) {
return {
info: `😅 200 - Cloudflare API :: DNS ${req.params['slug']} 🤣`,
result
};
}
throw new Error('Gagal Tarik Data DNS Zone');
return {
info: `😅 200 - Cloudflare API :: DNS ${req.params['slug']} 🤣`,
result
};
} catch (error) {
if (error instanceof HttpException) throw error;
throw new HttpException({
Expand Down
4 changes: 2 additions & 2 deletions src/api/controllers/verify-/verify-nik.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ export class VerifyNikController {
};
}
throw new HttpException({
info: `🙄 ${res_raw2.status || 400} - KTP API :: API Pemerintah Error 😪`,
info: `🙄 ${res_raw2.status || 500} - KTP API :: API Pemerintah Error 😪`,
result: {
message: 'Kayaknya Sudah Di Fix Deh Kebocoran Datanya?'
}
}, res_raw2.status || HttpStatus.BAD_REQUEST);
}, res_raw2.status || HttpStatus.INTERNAL_SERVER_ERROR);
}
throw new HttpException({
info: `🙄 ${res_raw1.status || 400} - Google API :: Captcha Bermasalah 😪`,
Expand Down

0 comments on commit b3a154c

Please sign in to comment.