trans-coord-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error handling


From: Yavor Doganov
Subject: Error handling
Date: Wed, 20 Feb 2008 17:07:34 +0200

On вт, 2008-02-12 at 23:35 +0200, Yavor Doganov wrote:
> a) Error handling.  There are several types of errors, and I want all
> of them to be mailed to the relevant parties (i.e. the presumably
> "guilty" parties).

This is what I propose for the case when validate-html is not happy.

I'm not proud at all with this implementation.  I played with tee a lot,
and I couldn't find a convenient way to use it in this case.  The
problem being that "validate.html foo.html | tee err" returns success
even if foo.html is invalid.

Another problem which I spotted (regardless of the consequences from
this patch) is that in practice we'll get warnings only once for the
translated pages -- next time make will not attempt to rebuild them.
Thus, if a translator does not fix the problem in a day, the invalid
page may remain forever (forever == until the original or the PO
changes).

Deleting the target is out of question, and touching article.LANG.PO
doesn't seem to help.  We have to think about this.

Suggestions for improvements welcome, otherwise I think it's usable in
this state and I'll write the documentation if acceptable.
--- GNUmakefile 20 фев 2008 11:11:07 +0200      1.1
+++ GNUmakefile 20 фев 2008 16:56:55 +0200      
@@ -48,8 +48,19 @@
 VALIDATESKIP := echo "SKIP:"
 endif
 
+# Do not send warning mails by default unless NOTIFY=yes.
+ifneq (,$(findstring yes,$(NOTIFY)))
+NOTIFYSKIP :=
+else
+NOTIFYSKIP := echo "SKIP:"
+endif
+
 # Email addresses for notifications.
 devel_addr := address@hidden
+# FIXME: Change to www-discuss in the official instance.
+web_addr := address@hidden
+# FIXME: Change to trans-coord-discuss in the official instance.
+transl_addr := address@hidden
 
 rootdir := ../..
 
@@ -178,7 +189,9 @@
 # in order to prevent further messing up in the chain.  For
 # extra safety, exit with an error so that make does not
 # proceed to the next command.
-       $(VALIDATESKIP) $(VALIDATE-HTML) $<
+       $(VALIDATESKIP) $(VALIDATE-HTML) $< &> err.log \
+         || ($(NOTIFYSKIP) mail -s "[GNUN error] $(<F) is not valid XHTML" \
+               $(web_addr) < err.log ; cat err.log ; exit 1)
        $(MAKE-PROTOTYPE) --home --input=$< --generic=generic.html --output=$@ 
|| ($(RM) $@ ; exit 1)
        $(SED) --in-place "s/\$$Date.*\$$/<gnun>\0<\/gnun>/g" $@
 
@@ -216,7 +229,11 @@
 # FIXME: Remove this conditional when GNUN operates in `www', where we
 # want to validate everything.
 ifneq (,$(findstring $(1),bg))
-       $(VALIDATESKIP) $(VALIDATE-HTML) $$@
+# FIXME: Unfortunately if the target is not valid XHTML, make will
+# consider it up-to-date in the next run.
+       $(VALIDATESKIP) $(VALIDATE-HTML) $$@ &> err.log \
+         || ($(NOTIFYSKIP) mail -s "[GNUN error] $$(@F) is not valid XHTML" \
+               $(transl_addr) < err.log ; cat err.log ; exit 1)
 endif
 endef
 
@@ -226,7 +243,10 @@
 ### Rules for all other articles ###
 define article_pot_rules
 $(1).proto $(1).translinks: $(subst /po/,/,$(1).html)
-       $(VALIDATESKIP) $(VALIDATE-HTML) $$<
+       $(VALIDATESKIP) $(VALIDATE-HTML) $$< &> err.log \
+         || ($(NOTIFYSKIP) mail -s \
+               "[GNUN error] $$(subst $(rootdir),,$$<) is not valid XHTML" \
+               $(web_addr) < err.log ; cat err.log ; exit 1)
        $(MAKE-PROTOTYPE) --input=$$< --generic=generic.html 
--output=$(1).proto --translinks=$(1).translinks || \
          ($(RM) $(1).proto $(1).translinks ; exit 1)
        $(SED) --in-place "s/\$$$$Date.*\$$$$/<gnun>\0<\/gnun>/g" $(1).proto
@@ -252,7 +272,12 @@
                $(SED) --in-place "s/\(<!--#include 
virtual=\".*$$$$replaceable\)\(.html\" -->\)/\1.$(2)\2/g" $(1).m4; \
        done;
        $(M4) $(1).m4 > $$@
-       $(VALIDATESKIP) $(VALIDATE-HTML) $$@
+# FIXME: Find a way to treat the target as not rebuilt if the page is
+# invalid.
+       $(VALIDATESKIP) $(VALIDATE-HTML) $$@ &> err.log \
+         || ($(NOTIFYSKIP) mail -s \
+               "[GNUN error] $$(subst $(rootdir),,$$@) is not valid XHTML" \
+               $(transl_addr) < err.log ; cat err.log ; exit 1)
 endef
 
 $(foreach base,$(ALL_BASE),$(eval $(call article_pot_rules,$(base))))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]