From: Philipp Takacs Date: Mon, 25 Apr 2016 14:19:54 +0000 (+0200) Subject: better error handling X-Git-Tag: mmh-0.3~30 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=ac3066d2d563ce3b9de66195f6818eecb594fec2;p=mmh better error handling only warn for LENERR2, or ignore it in some cases --- diff --git a/sbr/readconfig.c b/sbr/readconfig.c index 6975d72..45e1cb6 100644 --- a/sbr/readconfig.c +++ b/sbr/readconfig.c @@ -48,6 +48,9 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) for (state = FLD2;;) { switch (state = m_getfld2(state, &f, ib)) { + case LENERR2: + state = FLD2; + /* FALL */ case FLD2: np = mh_xcalloc(1, sizeof(*np)); *npp = np; @@ -68,7 +71,10 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) } } continue; - + case FMTERR2: + advise(NULL, "%s is poorly formated", file); + state = FLD2; + continue; case BODY2: adios(EX_CONFIG, NULL, "no blank lines are permitted in %s", file); @@ -76,6 +82,10 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx) case FILEEOF2: break; + case IOERR2: + adios(EX_IOERR, NULL, "m_getfld2", "some error happend"); + break; + default: adios(EX_CONFIG, NULL, "%s is poorly formatted", file); } diff --git a/uip/mhparse.c b/uip/mhparse.c index 67d769c..c250675 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -250,6 +250,10 @@ get_content(FILE *in, char *file, int toplevel) */ for (compnum = 1, state = FLD2;;) { switch (state = m_getfld2(state, &f, in)) { + case LENERR2: + advise(NULL, "To long field"); + state = FLD2; + /* FALL */ case FLD2: compnum++; @@ -267,11 +271,13 @@ get_content(FILE *in, char *file, int toplevel) ct->c_begin = ftell(in); break; - case LENERR2: case FMTERR2: + advise(NULL, "message format error in component #%d", compnum); + state = FLD2; + continue; + case IOERR2: - adios(EX_DATAERR, NULL, "message format error in component #%d", - compnum); + adios(EX_IOERR, "m_getfld2", "io error"); default: adios(EX_SOFTWARE, NULL, "getfld() returned %d", state); diff --git a/uip/new.c b/uip/new.c index 4335892..efbea04 100644 --- a/uip/new.c +++ b/uip/new.c @@ -108,6 +108,10 @@ get_msgnums(char *folder, char *sequences[]) for (state = FLD2;;) { switch (state = m_getfld2(state, &f, fp)) { + case LENERR2: + state = FLD2; + /* FALL */ + case FLD2: /* ** if it's in a sequence we want, diff --git a/uip/pick.c b/uip/pick.c index 5df2861..b0205fd 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -1261,8 +1261,12 @@ plist case LENERR2: case FMTERR2: - case IOERR2: advise(NULL, "format error in message %d", msgnum); + state = FLD2; + continue; + + case IOERR2: + adios(EX_IOERR, "m_getfld2", "io error on message %d", msgnum); /* FALL */ case BODY2: diff --git a/uip/prompter.c b/uip/prompter.c index c7eb957..bc7cd43 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -140,6 +140,10 @@ main(int argc, char **argv) */ for (state = FLD2;;) { switch (state = m_getfld2(state, &f, in)) { + case LENERR2: + advise(NULL, "Header to long"); + state = FLD2; + /* FALL */ case FLD2: /* ** Check if the value of field contains @@ -212,6 +216,9 @@ abort: } } while ((state = m_getfld2(state, &f, in)) ==BODY2); + if (state != FILEEOF2) { + adios(EX_IOERR, "m_getfld2", "io error"); + } } if (prepend || !qbody) { @@ -230,8 +237,11 @@ has_no_body: } break; + case FMTERR2: + advise(NULL, "skeleton is poorly formatted"); + continue; default: - adios(EX_DATAERR, NULL, "skeleton is poorly formatted"); + adios(EX_IOERR, "m_getfld2", "io error"); } break; } diff --git a/uip/slocal.c b/uip/slocal.c index f8f9d95..26cad52 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -758,6 +758,11 @@ parse(int fd) */ for (i = 0, state = FLD2;;) { switch (state = m_getfld2(state, &f, in)) { + case LENERR2: + advise(NULL, "format error in message"); + state = FLD2; + /* FALL */ + case FLD2: lp = mh_xstrdup(f.value); for (p = hdrs; p->p_name; p++) { @@ -793,7 +798,6 @@ parse(int fd) case FILEEOF2: break; - case LENERR2: case FMTERR2: case IOERR2: advise(NULL, "format error in message"); diff --git a/uip/sortm.c b/uip/sortm.c index 56fa7cb..061ae5a 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -331,6 +331,10 @@ get_fields(char *datesw, int msg, struct smsg *smsg) } for (compnum = 1, state = FLD2;; compnum++) { switch (state = m_getfld2(state, &f, in)) { + case LENERR2: + admonish(NULL, "To long header field in message %d (header %s, #%d)", msg, f.name, compnum); + state = FLD2; + /* FALL */ case FLD2: if (mh_strcasecmp(f.name, datesw)==0) { datecomp = mh_xstrdup(f.value); @@ -350,7 +354,6 @@ get_fields(char *datesw, int msg, struct smsg *smsg) case FILEEOF2: break; - case LENERR2: case FMTERR2: case IOERR2: admonish(NULL, "format error in message %d (header #%d)", msg, compnum); diff --git a/uip/whom.c b/uip/whom.c index daca343..e02994f 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -215,6 +215,10 @@ process(char *file) for (compnum=1, state=FLD2;; compnum++) { switch (state = m_getfld2(state, &f, in)) { + case LENERR2: + advise(NULL, "field %d contains a to long line", f.name); + state = FLD2; + /* FALL */ case FLD2: proc_hdr(f.name, f.value); continue; @@ -223,7 +227,6 @@ process(char *file) case FILEEOF2: break; - case LENERR2: case FMTERR2: case IOERR2: adios(EX_DATAERR, NULL, "message format error in component #%d",