parseCode static method
Program
parseCode(
- String code
)
Implementation
static Program parseCode(String code) {
if (code.isEmpty) {
throw JSException(1,
"Empty string is being passed as javascript code to parse. Please check your javascript code and fix it");
}
try {
return parsejs(code);
} on ParseError catch (e) {
final line = e.line ?? 1;
final column = _columnForOffset(code, e.startOffset);
throw JSException(
line,
"JavaScript parse error: ${e.message}.",
column: column,
recovery: parsingErrorAppendage,
detailedError: _formatParseDetails(code, line, column),
originalError: e,
);
} catch (error) {
throw JSException(
1,
"JavaScript parse error: ${error.toString()}.",
recovery: parsingErrorAppendage,
detailedError: _formatParseDetails(code, 1, 1),
originalError: error,
);
}
}