Changeset: ddb211719f4a for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ddb211719f4a
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/mal/mal_exception.c
        monetdb5/mal/mal_exception.h
        monetdb5/mal/mal_session.c
Branch: Dec2011
Log Message:

MAL: cleanup exception raising a little

Multiple exceptions can be returned in a single string, separated by
newlines.  Pass them as-is, prefixing each of then with a bang, without
disguising them as a single error.


diffs (80 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -5755,6 +5755,7 @@ str divRef;
 str doALGfetch(ptr ret, BAT *b, lng *pos);
 str doneRef;
 int dropRegist(str sch, str tab, str col, int acc);
+void dumpExceptionsToStream(stream *out, str msg);
 void dumpHelpTable(stream *f, Module s, str text, int flag);
 void dumpManual(stream *f, Module v, int recursive);
 void dumpManualFooter(stream *f);
diff --git a/monetdb5/mal/mal_exception.c b/monetdb5/mal/mal_exception.c
--- a/monetdb5/mal/mal_exception.c
+++ b/monetdb5/mal/mal_exception.c
@@ -208,8 +208,8 @@ createException(enum malexception type, 
  * Internal helper function to properly emit the given string to out,
  * thereby abiding to all the protocol laws.
  */
-static void
-dumpToStream(stream *out, str whatever) {
+void
+dumpExceptionsToStream(stream *out, str whatever) {
        size_t i;
        size_t last = 0;
        size_t len ;
@@ -244,15 +244,11 @@ showException(enum malexception type, co
        va_list ap;
        str msg;
 
-       /* ignore an internal exception */
-       if (strcmp(fcn, "client.quit") == 0)
-               return;
-
        va_start(ap, format);
        msg = createExceptionInternal(type, fcn, format, ap);
        va_end(ap);
 
-       dumpToStream(GDKout, msg);
+       dumpExceptionsToStream(GDKout, msg);
        GDKfree(msg);
 }
 
@@ -322,7 +318,7 @@ showScriptException(MalBlkPtr mb, int pc
        msg = createScriptExceptionInternal(mb, pc, type, NULL, format, ap);
        va_end(ap);
 
-       dumpToStream(GDKout,msg);
+       dumpExceptionsToStream(GDKout,msg);
        GDKfree(msg);
 }
 
diff --git a/monetdb5/mal/mal_exception.h b/monetdb5/mal/mal_exception.h
--- a/monetdb5/mal/mal_exception.h
+++ b/monetdb5/mal/mal_exception.h
@@ -69,6 +69,7 @@ mal_export enum malexception  getExceptio
 mal_export str getExceptionPlace(str);
 mal_export str getExceptionMessage(str);
 mal_export str exceptionToString(enum malexception);
+mal_export void dumpExceptionsToStream(stream *out, str msg);
 mal_export char *M5OutOfMemory;        /* pointer to constant string */
 
 #include "mal_errors.h"
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -630,9 +630,11 @@ MALengine(Client c)
        if (prg->def->errors == 0)
                msg = (str) runMAL(c, prg->def, 1, 0, c->glb, 0);
        if (msg) {
-               str place = getExceptionPlace(msg);
-               showException(getExceptionType(msg), place, "%s", 
getExceptionMessage(msg));
-               GDKfree(place);
+               /* ignore "internal" exceptions */
+               str fcn = getExceptionPlace(msg); /* retrieves from "first" 
exception */
+               if (strcmp(fcn, "client.quit") != 0)
+                       dumpExceptionsToStream(c->fdout, msg);
+               GDKfree(fcn);
                if (!c->listing)
                        printFunction(c->fdout, c->curprg->def, 0, c->listing);
                showErrors(c);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to