/**
 * Serve something wrong html.
 * @function serverside.middleware.defineSomethingWrongMiddleware
 * @param {object} context - Server context object.
 * @returns {function} - A something wrong middleware.
 * @author Taka Okunishi
 *
 */
module.exports = function (context) {
    return function (err, req, res, next) {
        if (!req.lang) {
            next(new Error('Method missing: req.lang'));
        }
        if (!res.somethingWrong) {
            next(new Error('Method missing: res.somethingWrong'));
        }
        var lang = req.lang();
        res.somethingWrong(lang, function (err) {
            if (err) next(err);
        });
    }
};