|
@@ -1,4 +1,4 @@
|
|
|
-const Errors = {
|
|
|
+let Errors = {
|
|
|
unknown: 'An unknown error occured on our end. Please try again later',
|
|
|
accountAlreadyCreated: 'This account has already been created',
|
|
|
missingParameter (param) {
|
|
@@ -15,14 +15,31 @@ const Errors = {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-for(var errorName in Errors) {
|
|
|
- var temp = {}
|
|
|
- temp.name = errorName
|
|
|
- temp.message = Errors[errorName]
|
|
|
+let ProcessedErrors = {}
|
|
|
+function processErrors(errorName) {
|
|
|
+ let temp
|
|
|
+
|
|
|
+ if(typeof Errors[errorName] === 'function') {
|
|
|
+ temp = function() {
|
|
|
+ let message = Errors[errorName](...arguments)
|
|
|
+ return {
|
|
|
+ name: errorName,
|
|
|
+ message: message
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ temp = {}
|
|
|
+ temp.name = errorName
|
|
|
+ temp.message = Errors[errorName]
|
|
|
+ }
|
|
|
|
|
|
- Errors[errorName] = temp
|
|
|
+ return temp
|
|
|
+}
|
|
|
+
|
|
|
+for(var errorName in Errors) {
|
|
|
+ ProcessedErrors[errorName] = processErrors(errorName)
|
|
|
}
|
|
|
|
|
|
-Errors.VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
|
+ProcessedErrors.VALIDATION_ERROR = 'VALIDATION_ERROR';
|
|
|
|
|
|
-module.exports = Errors
|
|
|
+module.exports = ProcessedErrors
|