1
0
mirror of https://github.com/rkd77/elinks.git synced 2025-01-03 14:57:44 -05:00

[smjs] Error Reporting with open_memstream

This commit is contained in:
Witold Filipczyk 2021-09-06 20:36:10 +02:00
parent 024f4f44b6
commit 30d4eb36ff

View File

@ -42,43 +42,28 @@ alert_smjs_error(char *msg)
static void static void
error_reporter(JSContext *ctx, JSErrorReport *report) error_reporter(JSContext *ctx, JSErrorReport *report)
{ {
#if 0 char *ptr;
char *warning; size_t size;
FILE *f = open_memstream(&ptr, &size);
if (f) {
struct string msg; struct string msg;
JS::UniqueChars prefix; JS::PrintError(ctx, f, report, true/*reportWarnings*/);
fclose(f);
if (!init_string(&msg)) goto reported; if (!init_string(&msg)) {
free(ptr);
warning = report->isWarning() ? " warning" : " error"; return;
#endif
JS::PrintError(ctx, stderr, report, true/*reportWarnings*/);
#if 0
add_format_to_string(&msg, "A client script raised the following%s",
warning);
add_to_string(&msg, ":\n\n");
add_format_to_string(&msg, "\n\n%d:%d ", report->lineno, report->column);
if (report->filename) {
prefix = JS_smprintf("%s:", report->filename);
} }
add_to_string(&msg, "A client script raised the following:\n");
if (report->lineno) { add_bytes_to_string(&msg, ptr, size);
prefix = JS_smprintf("%s%u:%u ", prefix, report->lineno, report->column); free(ptr);
}
if (prefix) {
add_to_string(&msg, prefix.get());
}
alert_smjs_error(msg.source); alert_smjs_error(msg.source);
done_string(&msg); done_string(&msg);
}
reported:
JS_ClearPendingException(ctx); JS_ClearPendingException(ctx);
#endif
} }
static int static int