Fixed error logged for absent redirects config

refs #11085

- Incorrect usage error was logged to the output when there was no recirecst configuration file present in the system. Previously an empty string was returned in such situation, resulting in "ENOENT" error, which was ignored through special handling.
- The fix resembles logic in redirects async getter function where empty array is returned when the config file does not exits.
- Attempting to read unexistent config should not ever happen and will be handled on the config service layer, this is why special "ENOENT" handling has been removed
This commit is contained in:
Naz 2020-11-05 12:45:02 +13:00
parent 142f5d389d
commit f69526c140
2 changed files with 6 additions and 1 deletions

View File

@ -191,6 +191,11 @@ const get = () => {
const loadRedirectsFile = () => {
const filePath = getCurrentRedirectsFilePathSync();
if (filePath === null) {
return defaultJsonFileContent;
}
const content = fs.readFileSync(filePath);
return parseRedirectsFile(content, path.extname(filePath));

View File

@ -75,7 +75,7 @@ _private.registerRoutes = () => {
} catch (err) {
if (errors.utils.isIgnitionError(err)) {
logging.error(err);
} else if (err.code !== 'ENOENT') {
} else {
logging.error(new errors.IncorrectUsageError({
message: i18n.t('errors.middleware.redirects.register'),
context: err.message,