From: <ny...@us...> - 2006-07-10 18:32:49
|
Revision: 128 Author: nyaochi Date: 2006-07-10 11:32:34 -0700 (Mon, 10 Jul 2006) ViewCVS: http://svn.sourceforge.net/pmplib/?rev=128&view=rev Log Message: ----------- Improved error messages when JavaScript errors occur. Modified Paths: -------------- trunk/frontend/easypmp/common/easypmp.h trunk/frontend/easypmp/common/playlist.c trunk/frontend/easypmp/cui/main.c trunk/include/playlist.h trunk/lib/playlist/jspl.c Modified: trunk/frontend/easypmp/common/easypmp.h =================================================================== --- trunk/frontend/easypmp/common/easypmp.h 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/common/easypmp.h 2006-07-10 18:32:34 UTC (rev 128) @@ -31,26 +31,28 @@ #endif/*__cplusplus*/ enum { - EASYPMPDBP_START = 0x00010000, - EASYPMPDBP_READ = 0x00020000, - EASYPMPDBP_GMI = 0x00030000, - EASYPMPDBP_UPDATE = 0x00040000, - EASYPMPDBP_WRITE = 0x00050000, - EASYPMPDBP_END = 0x00060000, + EASYPMPDBP_START = 0x00010000, + EASYPMPDBP_READ = 0x00020000, + EASYPMPDBP_GMI = 0x00030000, + EASYPMPDBP_UPDATE = 0x00040000, + EASYPMPDBP_WRITE = 0x00050000, + EASYPMPDBP_END = 0x00060000, - EASYPMPPLP_START = 0x01000000, - EASYPMPPLP_CONVERT = 0x02000000, - EASYPMPPLP_END = 0x03000000, + EASYPMPPLP_START = 0x01000000, + EASYPMPPLP_CONVERT = 0x02000000, + EASYPMPPLP_END = 0x03000000, - EASYPMPSP_START = 0x00000001, - EASYPMPSP_PROGRESS = 0x00000002, - EASYPMPSP_SKIPPED = 0x00000003, - EASYPMPSP_WARN_PLAYLIST = 0x00000004, - EASYPMPSP_SKIP_PLAYLIST = 0x00000005, - EASYPMPSP_MISSING_MEDIA = 0x00000006, - EASYPMPSP_JSPL_ERROR = 0x00000007, - EASYPMPSP_JSPL_OUTPUT = 0x00000008, - EASYPMPSP_END = 0x00000009, + EASYPMPSP_START = 0x00000001, + EASYPMPSP_PROGRESS = 0x00000002, + EASYPMPSP_SKIPPED = 0x00000003, + EASYPMPSP_WARN_PLAYLIST = 0x00000004, + EASYPMPSP_SKIP_PLAYLIST = 0x00000005, + EASYPMPSP_MISSING_MEDIA = 0x00000006, + EASYPMPSP_JSPL_ERROR = 0x00000007, + EASYPMPSP_JSPL_ERROR_POS = 0x00000008, + EASYPMPSP_JSPL_ERROR_LINE = 0x00000009, + EASYPMPSP_JSPL_OUTPUT = 0x0000000A, + EASYPMPSP_END = 0x0000000B, }; enum { Modified: trunk/frontend/easypmp/common/playlist.c =================================================================== --- trunk/frontend/easypmp/common/playlist.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/common/playlist.c 2006-07-10 18:32:34 UTC (rev 128) @@ -47,9 +47,11 @@ callback_data_t* cd = (callback_data_t*)instance; switch (level) { - case PLCALLBACK_JSPL_MESSAGE: phase |= EASYPMPSP_JSPL_OUTPUT; break; - case PLCALLBACK_JSPL_ERROR: phase |= EASYPMPSP_JSPL_ERROR; break; - default: phase |= EASYPMPSP_PROGRESS; break; + case PLCALLBACK_JSPL_MESSAGE: phase |= EASYPMPSP_JSPL_OUTPUT; break; + case PLCALLBACK_JSPL_ERROR: phase |= EASYPMPSP_JSPL_ERROR; break; + case PLCALLBACK_JSPL_ERROR_POS: phase |= EASYPMPSP_JSPL_ERROR_POS; break; + case PLCALLBACK_JSPL_ERROR_LINE: phase |= EASYPMPSP_JSPL_ERROR_LINE; break; + default: phase |= EASYPMPSP_PROGRESS; break; } cd->progress(cd->instance, phase, 0, 0, message); Modified: trunk/frontend/easypmp/cui/main.c =================================================================== --- trunk/frontend/easypmp/cui/main.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/frontend/easypmp/cui/main.c 2006-07-10 18:32:34 UTC (rev 128) @@ -151,6 +151,12 @@ case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR: fprints(fpe, " JSPL(ERROR): %s\n", param_str); break; + case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_POS: + fprints(fpe, " at: %s\n", param_str); + break; + case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_ERROR_LINE: + fprints(fpe, " line: %s\n", param_str); + break; case EASYPMPPLP_CONVERT|EASYPMPSP_JSPL_OUTPUT: fprints(fpe, " JSPL: %s\n", param_str); break; Modified: trunk/include/playlist.h =================================================================== --- trunk/include/playlist.h 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/include/playlist.h 2006-07-10 18:32:34 UTC (rev 128) @@ -45,6 +45,8 @@ PLCALLBACK_NONE, PLCALLBACK_JSPL_MESSAGE, PLCALLBACK_JSPL_ERROR, + PLCALLBACK_JSPL_ERROR_POS, + PLCALLBACK_JSPL_ERROR_LINE, }; enum { Modified: trunk/lib/playlist/jspl.c =================================================================== --- trunk/lib/playlist/jspl.c 2006-07-10 16:51:26 UTC (rev 127) +++ trunk/lib/playlist/jspl.c 2006-07-10 18:32:34 UTC (rev 128) @@ -93,9 +93,25 @@ static void error_handler(JSContext *cx, const char *message, JSErrorReport *report) { jspl_t* jspl = (jspl_t*)JS_GetContextPrivate(cx); - ucs2char_t* ucs2 = mbsdupucs2(message); + ucs2char_t* ucs2 = NULL; + char *pos = alloca(strlen(report->filename) + 64); /* extra 64 bytes for line numbers. */ + + ucs2 = mbsdupucs2(message); jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR, ucs2); ucs2free(ucs2); + + sprintf(pos, "lines %d in %s", report->lineno, report->filename); + ucs2 = mbsdupucs2(pos); + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_POS, ucs2); + ucs2free(ucs2); + + if (report->uclinebuf) { + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_LINE, (ucs2char_t*)report->uclinebuf); + } else { + ucs2 = mbsdupucs2(report->linebuf); + jspl->callback(jspl->instance, PLCALLBACK_JSPL_ERROR_LINE, ucs2); + ucs2free(ucs2); + } } static int function_exists(jspl_t* jspl, const char *funcname) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |