MCPcopy Index your code
hub / github.com/restify/node-restify / formatterError

Function formatterError

lib/response.js:900–921  ·  view source on GitHub ↗

* formatterError is used to handle any case where we were unable to * properly format the provided body * * @private * @function formatterError * @param {Response} res - response * @param {Error} err - error * @param {String} [msg] - custom log message * @returns {Response} response

(res, err, msg)

Source from the content-addressed store, hash-verified

898 * @returns {Response} response
899 */
900function formatterError(res, err, msg) {
901 // If the user provided a non-success error code, we don't want to
902 // mess with it since their error is probably more important than
903 // our inability to format their message.
904 if (res.statusCode >= 200 && res.statusCode < 300) {
905 res.statusCode = err.statusCode;
906 }
907
908 if (typeof msg !== 'string') {
909 msg = 'error retrieving formatter';
910 }
911
912 res.log.warn(
913 {
914 req: res.req,
915 err: err
916 },
917 msg
918 );
919
920 return flush(res);
921}
922
923module.exports = patch;

Callers 1

patchFunction · 0.85

Calls 1

flushFunction · 0.85

Tested by

no test coverage detected