* add wildfire output to errormessages
authorWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 00:30:54 +0000 (00:30 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 26 Jan 2009 00:30:54 +0000 (00:30 +0000)
webcit/subst.c
webcit/webcit.c
webcit/webcit.h

index b22220627f576cce1d4fc13a0618375c09561198..8dda6fb0d44124e4c3417060ba04565094d872c9 100644 (file)
@@ -113,6 +113,8 @@ const char *ContextName(int ContextType)
 
 void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplputParams *TP, const char *Format, ...)
 {
+       wcsession *WCC;
+       StrBuf *Header;
        StrBuf *Error;
        StrBuf *Info;
         va_list arg_ptr;
@@ -155,8 +157,11 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
        }
        if (Target == NULL) 
                return;
+       WCC = WC;
+       Header = NewStrBuf();
        if (TP->Tokens != NULL) 
        {
+               /* deprecated: 
                StrBufAppendPrintf(                                                          
                        Target,                                                              
                        "<pre>\n%s [%s] (in '%s' line %ld); %s\n[%s]\n</pre>\n",
@@ -166,18 +171,37 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
                        TP->Tokens->Line,
                        ChrPtr(Error),
                        ChrPtr(TP->Tokens->FlatToken));
+               */
+
+               SerializeJson(Header, WildFireException(SKEY(TP->Tokens->FileName),
+                                                       TP->Tokens->Line,
+                                                       Error,
+                                                       1), 1);
+/*
+               SerializeJson(Header, WildFireMessage(SKEY(TP->Tokens->FileName),
+                                                     TP->Tokens->Line,
+                                                     Error,
+                                                     eERROR), 1);
+*/
+               WildFireSerializePayload(Header, WCC->HBuf, &WCC->nWildfireHeaders, NULL);
        }
        else
        {
+               /* deprecated.
                StrBufAppendPrintf(                                                          
                        Target,                                                              
                        "<pre>\n%s: %s\n</pre>\n",
                        Type, 
                        ChrPtr(Error));
+               */
+               SerializeJson(Header, WildFireException(HKEY(__FILE__), __LINE__, Error, 1), 1);
+               WildFireSerializePayload(Header, WCC->HBuf, &WCC->nWildfireHeaders, NULL);
        }
+       FreeStrBuf(&Header);
+/*
        if (dbg_bactrace_template_errors)
                wc_backtrace(); 
-
+*/
 }
 
 
@@ -757,7 +781,7 @@ void print_value_of(StrBuf *Target, WCTemplputParams *TP)
        else {
                LogTemplateError(
                        Target, "Token", ERR_NAME, TP,
-                       "didn't find Handler");
+                       "didn't find Handler \"%s\"", TP->Tokens->pName);
                wc_backtrace();
        }
 }
index 7abf512d6a739da4944fa51af6e2dcde7926fda2..49884f250599197380206c1bb49990eca435ca42 100644 (file)
@@ -590,6 +590,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
        WCC->upload = NULL;
        WCC->is_mobile = 0;
        WCC->trailing_javascript = NewStrBuf();
+       WCC->nWildfireHeaders = 0;
 
        /** Figure out the action */
        index[0] = action;
index afc4bdf56f976b1f275b320c37cc9e48cc070695..545089bad1373dc80cd257db1175b4efdf8b9d8a 100644 (file)
@@ -356,6 +356,7 @@ struct wcsession {
        StrBuf *http_host;                      /**< HTTP Host: header */
        int is_ajax;                            /** < are we doing an ajax request? */
        int gzip_ok;                            /**< Nonzero if Accept-encoding: gzip */
+       int nWildfireHeaders;                   /**< how many wildfire headers did we already send? */
 
        StrBuf *trailing_javascript;            /**< extra javascript to be appended to page */
        char ImportantMessage[SIZ];             /**< ??? todo */