Skip to content

Commit 34eed9a

Browse files
committed
Small modifications in response to pull request conversations
1 parent fd3395d commit 34eed9a

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

lib/converters/html-converter.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ module.exports = class HtmlConverter extends Converter {
109109

110110
/**
111111
* This is a wrapper around convert(), that will render some default HTML if the expected conversion fails.
112-
* Useful in error conditions.
113112
*
114-
* @param htmlInfo - see convert()
115-
* @param data - see convert()
113+
* Call this function in stead of convert(), to complete requests in error conditions.
114+
*
115+
* @param htmlInfo - The information about HTML (path, engine)
116+
* @param data - The JSON data that is used by the engine to substitute variables.
116117
*
117118
* @param message - {string} text to display inside a paragraph of the default HTML, if data cannot be converted as expected
118119
* @param logger - optional logger instance, logs conversion error that causes default HTML rendering

lib/handlers/request-handler.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,8 @@ module.exports = class RequestHandler extends Handler {
6161
}
6262

6363
const handleResponse = this.responseHandler.handle(res, status, 'text/html');
64-
65-
if (!htmlInfo[String(status)]) {
66-
this.logger.warn(`No HTML template is defined for status code ${status}. Sending an empty string instead.`);
67-
handleResponse('');
68-
} else {
69-
const html = await HTMLConverter.convertWithDefault(htmlInfo[String(status)], {}, `Status: ${status}`, this.logger);
70-
handleResponse(html);
71-
}
64+
const html = await HTMLConverter.convertWithDefault(htmlInfo[String(status)], {}, `Status: ${status}`, this.logger);
65+
handleResponse(html);
7266
})
7367
} else {
7468
// No GraphQL query is defined, so we just use the template without data.

lib/validators/main-validator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module.exports = class MainValidator {
8484
});
8585

8686
if (hasErrors) {
87-
let err = new Error(output.join('\n'));
87+
const err = new Error(output.join('\n'));
8888
err.type = 'VALIDATION_ERROR';
8989
throw err;
9090
}

0 commit comments

Comments
 (0)