Explorar el Código

Add meaningful error messages

Alois Mahdal hace 6 años
padre
commit
439ec34224
Se han modificado 1 ficheros con 13 adiciones y 3 borrados
  1. 13
    3
      src/imapdomo.skel

+ 13
- 3
src/imapdomo.skel Ver fichero

24
        "are also available in .imapdomo/common.lua"
24
        "are also available in .imapdomo/common.lua"
25
 }
25
 }
26
 
26
 
27
+bug() {
28
+    #
29
+    # Die because of bug
30
+    #
31
+    local msg=$1
32
+    local self
33
+    self=$(basename "$0")
34
+    die "bug in $self (__MKIT_PROJ_VERSION__): $msg"
35
+}
36
+
27
 mkcmd() {
37
 mkcmd() {
28
     #
38
     #
29
     # Compose imapfilter command
39
     # Compose imapfilter command
86
      || dle "no handler for action: $Action.lua in $IMAPDOMO_HOME/handlers"
96
      || dle "no handler for action: $Action.lua in $IMAPDOMO_HOME/handlers"
87
     cmd=$(mkcmd)
97
     cmd=$(mkcmd)
88
     debug -v cmd
98
     debug -v cmd
89
-    bash -n <<<"$cmd" || die
99
+    bash -n <<<"$cmd" || bug "bad syntax of cmd: '$cmd'"
90
     if test -n "$CdTo";
100
     if test -n "$CdTo";
91
     then
101
     then
92
-        cd "$CdTo" || die
102
+        cd "$CdTo" || die "cannot chdir to: $CdTo"
93
     fi
103
     fi
94
-    mkdir -p "$HeaderDir" || die
104
+    mkdir -p "$HeaderDir" || die "cannot create header directory: $HeaderDir"
95
     eval "$cmd"
105
     eval "$cmd"
96
 }
106
 }
97
 
107