| 220 | } |
| 221 | |
| 222 | std::string print_string_value(JSContext* cx, JS::HandleValue v_string) { |
| 223 | if (!v_string.isString()) |
| 224 | return "[unexpected result from printing value]"; |
| 225 | |
| 226 | JS::RootedString printed_string(cx, v_string.toString()); |
| 227 | JS::AutoSaveExceptionState exc_state(cx); |
| 228 | JS::UniqueChars chars(JS_EncodeStringToUTF8(cx, printed_string)); |
| 229 | exc_state.restore(); |
| 230 | if (!chars) |
| 231 | return "[error printing value]"; |
| 232 | |
| 233 | return chars.get(); |
| 234 | } |
| 235 | |
| 236 | /* Return value of false indicates an uncatchable exception, rather than any |
| 237 | * exception. (This is because the exception should be auto-printed around the |
no test coverage detected