Skip to content

Commit 4ad4527

Browse files
committed
feat(global): general error added
1 parent ff1c589 commit 4ad4527

File tree

10 files changed

+105
-52
lines changed

10 files changed

+105
-52
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"access": "public"
1010
},
1111
"devDependencies": {
12-
"@types/jest": "27.0.1",
13-
"@types/node": "16.9.4",
14-
"@typescript-eslint/eslint-plugin": "4.31.1",
15-
"@typescript-eslint/parser": "4.31.1",
12+
"@types/jest": "27.0.2",
13+
"@types/node": "16.10.0",
14+
"@typescript-eslint/eslint-plugin": "4.31.2",
15+
"@typescript-eslint/parser": "4.31.2",
1616
"eslint": "7.32.0",
1717
"eslint-config-prettier": "8.3.0",
1818
"eslint-plugin-prettier": "4.0.0",

src/codes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { IErrors } from './types';
22

33
// Resources
44
import authentication from './resources/authentication';
5+
import general from './resources/general';
56

67
const codes: IErrors = {
78
authentication,
9+
general,
810
};
911

1012
export { codes };

src/resources/authentication/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const authentication: IErrorRes = {
2222
status: EHttpCode.UNAUTHORIZED,
2323
},
2424
},
25+
internal: {},
26+
external: {},
2527
i18n,
2628
};
2729

src/resources/authentication/locales/en_US.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"unauthorizedRoute": "Access denied",
66
"unauthorizedResource": "Access denied",
77
"tokenExpired": "Token expired"
8-
}
8+
},
9+
"internal": {},
10+
"external": {}
911
}

src/resources/authentication/locales/fr_FR.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@
55
"unauthorizedRoute": "Accès refusé",
66
"unauthorizedResource": "Accès refusé",
77
"tokenExpired": "Token expiré"
8-
}
8+
},
9+
"internal": {},
10+
"external": {}
911
}

src/resources/general/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { II18n, IErrorRes, EHttpCode } from '../../types';
2+
3+
// Locals
4+
import * as fr_FR from './locales/fr_FR.json';
5+
import * as en_US from './locales/en_US.json';
6+
7+
const i18n: II18n = { fr_FR, en_US };
8+
9+
const general: IErrorRes = {
10+
client: {},
11+
internal: {
12+
unexpected: {
13+
status: EHttpCode.INTERNAL_SERVER_ERROR,
14+
},
15+
},
16+
external: {},
17+
i18n,
18+
};
19+
20+
export default general;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"client": { },
3+
"internal": {
4+
"unexpected": "An unexpected error occurred"
5+
},
6+
"external": {}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"client": {},
3+
"internal": {
4+
"unexpected": "Une erreur inattendue est survenue"
5+
},
6+
"external": {}
7+
}

src/types/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ interface IErrorRes {
7878
client: {
7979
[message: string]: ICode;
8080
};
81+
internal: {
82+
[message: string]: ICode;
83+
};
84+
external: {
85+
[message: string]: ICode;
86+
};
8187
i18n: II18n;
8288
}
8389

yarn.lock

Lines changed: 51 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,10 @@
622622
dependencies:
623623
"@types/istanbul-lib-report" "*"
624624

625-
"@types/jest@27.0.1":
626-
version "27.0.1"
627-
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.1.tgz#fafcc997da0135865311bb1215ba16dba6bdf4ca"
628-
integrity sha512-HTLpVXHrY69556ozYkcq47TtQJXpcWAWfkoqz+ZGz2JnmZhzlRjprCIyFnetSy8gpDWwTTGBcRVv1J1I1vBrHw==
625+
"@types/jest@27.0.2":
626+
version "27.0.2"
627+
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-27.0.2.tgz#ac383c4d4aaddd29bbf2b916d8d105c304a5fcd7"
628+
integrity sha512-4dRxkS/AFX0c5XW6IPMNOydLn2tEhNhJV7DnYK+0bjoJZ+QTmfucBlihX7aoEsh/ocYtkLC73UbnBXBXIxsULA==
629629
dependencies:
630630
jest-diff "^27.0.0"
631631
pretty-format "^27.0.0"
@@ -635,11 +635,16 @@
635635
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.9.tgz#97edc9037ea0c38585320b28964dde3b39e4660d"
636636
integrity sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==
637637

638-
"@types/node@*", "@types/node@16.9.4":
638+
"@types/node@*":
639639
version "16.9.4"
640640
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.9.4.tgz#a12f0ee7847cf17a97f6fdf1093cb7a9af23cca4"
641641
integrity sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpqlpgAAo6H/qnM9RjBgh0A0kmHf3XxAKLdN5mTIng9iUvVLA==
642642

643+
"@types/node@16.10.0":
644+
version "16.10.0"
645+
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.0.tgz#1cbca7c67ba9ff80675ada496f54a919e8c4c145"
646+
integrity sha512-In+/vAdT+kkHigDSN9lUDDmzsIyKn5efDcwmGGnBtZVHnBv1oDVn6vC0ckic9FxSm+X0BGJGECpI1ZOg60E21g==
647+
643648
"@types/prettier@^2.1.5":
644649
version "2.3.2"
645650
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.3.2.tgz#fc8c2825e4ed2142473b4a81064e6e081463d1b3"
@@ -662,73 +667,73 @@
662667
dependencies:
663668
"@types/yargs-parser" "*"
664669

665-
"@typescript-eslint/eslint-plugin@4.31.1":
666-
version "4.31.1"
667-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.1.tgz#e938603a136f01dcabeece069da5fb2e331d4498"
668-
integrity sha512-UDqhWmd5i0TvPLmbK5xY3UZB0zEGseF+DHPghZ37Sb83Qd3p8ujhvAtkU4OF46Ka5Pm5kWvFIx0cCTBFKo0alA==
670+
"@typescript-eslint/eslint-plugin@4.31.2":
671+
version "4.31.2"
672+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.31.2.tgz#9f41efaee32cdab7ace94b15bd19b756dd099b0a"
673+
integrity sha512-w63SCQ4bIwWN/+3FxzpnWrDjQRXVEGiTt9tJTRptRXeFvdZc/wLiz3FQUwNQ2CVoRGI6KUWMNUj/pk63noUfcA==
669674
dependencies:
670-
"@typescript-eslint/experimental-utils" "4.31.1"
671-
"@typescript-eslint/scope-manager" "4.31.1"
675+
"@typescript-eslint/experimental-utils" "4.31.2"
676+
"@typescript-eslint/scope-manager" "4.31.2"
672677
debug "^4.3.1"
673678
functional-red-black-tree "^1.0.1"
674679
regexpp "^3.1.0"
675680
semver "^7.3.5"
676681
tsutils "^3.21.0"
677682

678-
"@typescript-eslint/experimental-utils@4.31.1":
679-
version "4.31.1"
680-
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.1.tgz#0c900f832f270b88e13e51753647b02d08371ce5"
681-
integrity sha512-NtoPsqmcSsWty0mcL5nTZXMf7Ei0Xr2MT8jWjXMVgRK0/1qeQ2jZzLFUh4QtyJ4+/lPUyMw5cSfeeME+Zrtp9Q==
683+
"@typescript-eslint/experimental-utils@4.31.2":
684+
version "4.31.2"
685+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-4.31.2.tgz#98727a9c1e977dd5d20c8705e69cd3c2a86553fa"
686+
integrity sha512-3tm2T4nyA970yQ6R3JZV9l0yilE2FedYg8dcXrTar34zC9r6JB7WyBQbpIVongKPlhEMjhQ01qkwrzWy38Bk1Q==
682687
dependencies:
683688
"@types/json-schema" "^7.0.7"
684-
"@typescript-eslint/scope-manager" "4.31.1"
685-
"@typescript-eslint/types" "4.31.1"
686-
"@typescript-eslint/typescript-estree" "4.31.1"
689+
"@typescript-eslint/scope-manager" "4.31.2"
690+
"@typescript-eslint/types" "4.31.2"
691+
"@typescript-eslint/typescript-estree" "4.31.2"
687692
eslint-scope "^5.1.1"
688693
eslint-utils "^3.0.0"
689694

690-
"@typescript-eslint/parser@4.31.1":
691-
version "4.31.1"
692-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.31.1.tgz#8f9a2672033e6f6d33b1c0260eebdc0ddf539064"
693-
integrity sha512-dnVZDB6FhpIby6yVbHkwTKkn2ypjVIfAR9nh+kYsA/ZL0JlTsd22BiDjouotisY3Irmd3OW1qlk9EI5R8GrvRQ==
695+
"@typescript-eslint/parser@4.31.2":
696+
version "4.31.2"
697+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.31.2.tgz#54aa75986e3302d91eff2bbbaa6ecfa8084e9c34"
698+
integrity sha512-EcdO0E7M/sv23S/rLvenHkb58l3XhuSZzKf6DBvLgHqOYdL6YFMYVtreGFWirxaU2mS1GYDby3Lyxco7X5+Vjw==
694699
dependencies:
695-
"@typescript-eslint/scope-manager" "4.31.1"
696-
"@typescript-eslint/types" "4.31.1"
697-
"@typescript-eslint/typescript-estree" "4.31.1"
700+
"@typescript-eslint/scope-manager" "4.31.2"
701+
"@typescript-eslint/types" "4.31.2"
702+
"@typescript-eslint/typescript-estree" "4.31.2"
698703
debug "^4.3.1"
699704

700-
"@typescript-eslint/scope-manager@4.31.1":
701-
version "4.31.1"
702-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.31.1.tgz#0c21e8501f608d6a25c842fcf59541ef4f1ab561"
703-
integrity sha512-N1Uhn6SqNtU2XpFSkD4oA+F0PfKdWHyr4bTX0xTj8NRx1314gBDRL1LUuZd5+L3oP+wo6hCbZpaa1in6SwMcVQ==
705+
"@typescript-eslint/scope-manager@4.31.2":
706+
version "4.31.2"
707+
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.31.2.tgz#1d528cb3ed3bcd88019c20a57c18b897b073923a"
708+
integrity sha512-2JGwudpFoR/3Czq6mPpE8zBPYdHWFGL6lUNIGolbKQeSNv4EAiHaR5GVDQaLA0FwgcdcMtRk+SBJbFGL7+La5w==
704709
dependencies:
705-
"@typescript-eslint/types" "4.31.1"
706-
"@typescript-eslint/visitor-keys" "4.31.1"
710+
"@typescript-eslint/types" "4.31.2"
711+
"@typescript-eslint/visitor-keys" "4.31.2"
707712

708-
"@typescript-eslint/types@4.31.1":
709-
version "4.31.1"
710-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.31.1.tgz#5f255b695627a13401d2fdba5f7138bc79450d66"
711-
integrity sha512-kixltt51ZJGKENNW88IY5MYqTBA8FR0Md8QdGbJD2pKZ+D5IvxjTYDNtJPDxFBiXmka2aJsITdB1BtO1fsgmsQ==
713+
"@typescript-eslint/types@4.31.2":
714+
version "4.31.2"
715+
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.31.2.tgz#2aea7177d6d744521a168ed4668eddbd912dfadf"
716+
integrity sha512-kWiTTBCTKEdBGrZKwFvOlGNcAsKGJSBc8xLvSjSppFO88AqGxGNYtF36EuEYG6XZ9vT0xX8RNiHbQUKglbSi1w==
712717

713-
"@typescript-eslint/typescript-estree@4.31.1":
714-
version "4.31.1"
715-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.1.tgz#4a04d5232cf1031232b7124a9c0310b577a62d17"
716-
integrity sha512-EGHkbsUvjFrvRnusk6yFGqrqMBTue5E5ROnS5puj3laGQPasVUgwhrxfcgkdHNFECHAewpvELE1Gjv0XO3mdWg==
718+
"@typescript-eslint/typescript-estree@4.31.2":
719+
version "4.31.2"
720+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.31.2.tgz#abfd50594d8056b37e7428df3b2d185ef2d0060c"
721+
integrity sha512-ieBq8U9at6PvaC7/Z6oe8D3czeW5d//Fo1xkF/s9394VR0bg/UaMYPdARiWyKX+lLEjY3w/FNZJxitMsiWv+wA==
717722
dependencies:
718-
"@typescript-eslint/types" "4.31.1"
719-
"@typescript-eslint/visitor-keys" "4.31.1"
723+
"@typescript-eslint/types" "4.31.2"
724+
"@typescript-eslint/visitor-keys" "4.31.2"
720725
debug "^4.3.1"
721726
globby "^11.0.3"
722727
is-glob "^4.0.1"
723728
semver "^7.3.5"
724729
tsutils "^3.21.0"
725730

726-
"@typescript-eslint/visitor-keys@4.31.1":
727-
version "4.31.1"
728-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.1.tgz#f2e7a14c7f20c4ae07d7fc3c5878c4441a1da9cc"
729-
integrity sha512-PCncP8hEqKw6SOJY+3St4LVtoZpPPn+Zlpm7KW5xnviMhdqcsBty4Lsg4J/VECpJjw1CkROaZhH4B8M1OfnXTQ==
731+
"@typescript-eslint/visitor-keys@4.31.2":
732+
version "4.31.2"
733+
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.31.2.tgz#7d5b4a4705db7fe59ecffb273c1d082760f635cc"
734+
integrity sha512-PrBId7EQq2Nibns7dd/ch6S6/M4/iwLM9McbgeEbCXfxdwRUNxJ4UNreJ6Gh3fI2GNKNrWnQxKL7oCPmngKBug==
730735
dependencies:
731-
"@typescript-eslint/types" "4.31.1"
736+
"@typescript-eslint/types" "4.31.2"
732737
eslint-visitor-keys "^2.0.0"
733738

734739
abab@^2.0.3, abab@^2.0.5:

0 commit comments

Comments
 (0)