hsp/compiler/jsgenerator/index.js
function _getErrorScript (errors, fileName) {
    var result = '';
    if (errors && errors.length) {
        var err=errors[0];
        var ctxt={
            type:"error",
            file:fileName,
            code:err.code,
            line:err.line,
            column:err.column
        };
        var suberrors = err.suberrors;
        var suberrorsJsStr = ""; // varargs, should end up as sth like '"a", "b", "c"'
        if (suberrors && suberrors.length > 0) {
            var out = [];
            for (var k = 0; k < suberrors.length; k++) {
                out[k] = _toDoubleQuotedJsString(suberrors[k], '==> ');
            }
            suberrorsJsStr = out.join(', ') + ', ';
        }
        var descriptionJsStr = _toDoubleQuotedJsString(err.description);
        var metadata = JSON.stringify(ctxt, null);
        result = ['\r\nrequire("hsp/rt/log").error(', descriptionJsStr, ',', suberrorsJsStr, metadata ,');\r\n'].join("");
    }
    return result;
}
function _getErrorScript (errors, fileName) {
    var result = '';
    if (errors && errors.length) {
        var err=errors[0];
        var ctxt={
            type:"error",
            file:fileName,
            code:err.code,
            line:err.line,
            column:err.column
        };
        var suberrors = err.suberrors;
        var suberrorsJsStr = ""; // varargs, should end up as sth like '"a", "b", "c"'
        if (suberrors && suberrors.length > 0) {
            var out = [];
            for (var k = 0; k < suberrors.length; k++) {
                out[k] = _toDoubleQuotedJsString(suberrors[k], '==> ');
            }
            suberrorsJsStr = out.join(', ') + ', ';
        }
        var descriptionJsStr = _toDoubleQuotedJsString(err.description);
        var metadata = JSON.stringify(ctxt, null);
        result = ['\r\nrequire("hsp/rt/log").error(', descriptionJsStr, ',', suberrorsJsStr, metadata ,');\r\n'].join("");
    }
    return result;
}
function _getErrorScript ( errors , fileName ) { var result = '' ; if ( errors && errors . length ) { var err = errors [ 0 ] ; var ctxt = { type : "error" , file : fileName , code : err . code , line : err . line , column : err . column } ; var suberrors = err . suberrors ; var suberrorsJsStr = "" ; // varargs, should end up as sth like '"a", "b", "c"' if ( suberrors && suberrors . length > 0 ) { var out = [ ] ; for ( var k = 0 ; k < suberrors . length ; k ++ ) { out [ k ] = _toDoubleQuotedJsString ( suberrors [ k ] , '==> ' ) ; } suberrorsJsStr = out . join ( ', ' ) + ', ' ; } var descriptionJsStr = _toDoubleQuotedJsString ( err . description ) ; var metadata = JSON . stringify ( ctxt , null ) ; result = [ '\r\nrequire("hsp/rt/log").error(' , descriptionJsStr , ',' , suberrorsJsStr , metadata , ');\r\n' ] . join ( "" ) ; } return result ; }
Generate an error script to include in the template compiled script in order to show errors in the browser when the script is loaded
@param {Array} errors the errror list
@param {String} fileName the name of the file being compiled
@return {String} the javascript snippet to be included
Generate an error script to include in the template compiled script in order to show errors in the browser when the script is loaded