clone code
This commit is contained in:
parent
c9597d1e38
commit
d57bcd1719
362 changed files with 104804 additions and 0 deletions
41
src/global/user_response_msg.ts
Normal file
41
src/global/user_response_msg.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* GLOABL Response Message for User
|
||||
*
|
||||
*/
|
||||
import { useQuasar } from "quasar";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
|
||||
// const $q = useQuasar(); // show dialog Error:runtime-core.esm-bundler.js:40 [Vue warn]: inject() can only be used inside setup() or functional components.
|
||||
const mixin = useCounterMixin();
|
||||
const { success, modalConfirm, modalError, modalDelete } = mixin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param catchE throw catch error message (e)
|
||||
* @param q $q quasar dialog
|
||||
* @returns no values return only pop-up dialog message for user
|
||||
*/
|
||||
const manageApiErrorMsg = (catchE: any, q: any) => {
|
||||
// console.log(catchE);
|
||||
// console.log(catchE.response);
|
||||
// console.log(catchE.response.status);
|
||||
// if (!catchE || !catchE.response || !catchE.response.data) {
|
||||
// console.error("Invalid error object:", catchE);
|
||||
// return;
|
||||
// }
|
||||
if (catchE.response.status == 401 || catchE.response.data.status == 401) {
|
||||
modalError(q, "พบข้อผิดพลาด", "กรุณาล็อกอินใหม่อีกครั้ง"); //invalid_token
|
||||
} else if (
|
||||
catchE.response.data.status == 400 ||
|
||||
catchE.response.data.status == 403 ||
|
||||
catchE.response.data.status == 404
|
||||
) {
|
||||
//ใส่เป็น error กลางๆ ถ้ามีเคสให้เห็นมากขึ้น ถึงจะแยกข้อความได้
|
||||
modalError(q, "พบข้อผิดพลาด", "ไม่พบข้อมูล");
|
||||
} else {
|
||||
modalError(q, "พบข้อผิดพลาด", catchE.response.data.message);
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
export default manageApiErrorMsg;
|
||||
Loading…
Add table
Add a link
Reference in a new issue