MCPcopy Index your code
hub / github.com/beanshell/beanshell / formatScriptResultHTML

Method formatScriptResultHTML

src/bsh/servlet/BshServlet.java:156–191  ·  view source on GitHub ↗
( 
		String script, Object result, Exception error, 
		StringBuffer scriptOutput )

Source from the content-addressed store, hash-verified

154 /**
155 */
156 String formatScriptResultHTML(
157 String script, Object result, Exception error,
158 StringBuffer scriptOutput )
159 throws IOException
160 {
161 SimpleTemplate tmplt;
162
163 if ( error != null )
164 {
165 tmplt = new SimpleTemplate(
166 getClass().getResource("error.template") );
167
168 String errString;
169
170 if ( error instanceof bsh.EvalError )
171 {
172 int lineNo = ((EvalError)error).getErrorLineNumber();
173 String msg = error.getMessage();
174 int contextLines = 4;
175 errString = escape(msg);
176 if ( lineNo > -1 )
177 errString += "<hr>"
178 + showScriptContextHTML( script, lineNo, contextLines );
179 } else
180 errString = escape( error.toString() );
181
182 tmplt.replace("error", errString );
183 } else {
184 tmplt = new SimpleTemplate(
185 getClass().getResource("result.template") );
186 tmplt.replace( "value", escape(String.valueOf(result)) );
187 tmplt.replace( "output", escape(scriptOutput.toString()) );
188 }
189
190 return tmplt.toString();
191 }
192
193 /*
194 Show context number lines of string before and after target line.

Callers 1

sendHTMLMethod · 0.95

Calls 8

escapeMethod · 0.95
showScriptContextHTMLMethod · 0.95
toStringMethod · 0.95
replaceMethod · 0.95
getClassMethod · 0.80
getResourceMethod · 0.45
getErrorLineNumberMethod · 0.45
getMessageMethod · 0.45

Tested by

no test coverage detected