bufr2synop 0.24.0
Functions
bufr2tac_error.c File Reference

This file has the code for functions to manage errors in bufr2tac library. More...

#include "bufr2tac.h"
Include dependency graph for bufr2tac_error.c:

Go to the source code of this file.

Functions

int bufr2tac_push_error (struct bufr2tac_error_stack *e, int severity, char *description)
 
int bufr2tac_clean_error_stack (struct bufr2tac_error_stack *e)
 
int bufr2tac_set_error (struct bufr2tac_subset_state *s, int severity, char *origin, char *explanation)
 
int bufr2tac_print_error (struct bufr2tac_error_stack *e)
 

Detailed Description

This file has the code for functions to manage errors in bufr2tac library.

Definition in file bufr2tac_error.c.

Function Documentation

◆ bufr2tac_clean_error_stack()

int bufr2tac_clean_error_stack ( struct bufr2tac_error_stack e)

Definition at line 49 of file bufr2tac_error.c.

50{
51 if ( e != NULL )
52 {
53 memset ( e, 0, sizeof ( struct bufr2tac_error_stack ) );
54 return 0;
55 }
56 return -1;
57}
A stack of structs bufr2tac_error.
Definition: bufr2tac.h:235

◆ bufr2tac_print_error()

int bufr2tac_print_error ( struct bufr2tac_error_stack e)

Definition at line 87 of file bufr2tac_error.c.

88{
89 unsigned int i;
90 if ( e->ne == 0 )
91 {
92 printf ( "# No info/warning/error \n" );
93 return 0;
94 }
95
96 for ( i = 0; i < e->ne ; i++ )
97 {
98 if ( e->err[i].severity == 0 )
99 printf ( "# INFO: " );
100 else if ( e->err[i].severity == 1 )
101 printf ( "# WARNING: " );
102 else if ( e->err[i].severity == 2 )
103 printf ( "# ERROR: " );
104 else
105 {
106 printf ( "# %d\n", e->err[i].severity );
107 return 1;
108 }
109 printf ( "%s\n", e->err[i].description );
110 }
111 if ( e->full > 0 )
112 printf ( "# More debug info follows, stack of logs full\n" );
113 return 0;
114}
struct bufr2tac_error err[BUFR2TAC_ERROR_STACK_DIM]
Definition: bufr2tac.h:238
char description[BUFR2TAC_ERROR_DESCRIPTION_LENGTH]
Definition: bufr2tac.h:228

References bufr2tac_error::description, bufr2tac_error_stack::err, bufr2tac_error_stack::full, bufr2tac_error_stack::ne, and bufr2tac_error::severity.

Referenced by parse_subset_sequence().

Here is the caller graph for this function:

◆ bufr2tac_push_error()

int bufr2tac_push_error ( struct bufr2tac_error_stack e,
int  severity,
char *  description 
)

Definition at line 26 of file bufr2tac_error.c.

27{
28 // avoid segfaults
29 if ( e == NULL )
30 return -1; // Fatal error
31
33 {
34 e->err[e->ne].severity = severity;
35 strcpy ( e->err[e->ne].description, description );
36 ( e->ne )++;
37 return 1;
38 }
39 else if ( e->ne == BUFR2TAC_ERROR_STACK_DIM )
40 {
41 // Do not pull error, but annotate the stack as rebased
42 if ( e->full < severity )
43 e->full = severity;
44 return 0;
45 }
46 return -1; // bad e->ne
47}
#define BUFR2TAC_ERROR_STACK_DIM
set de dimension of a struct bufr2tac_error_stack
Definition: bufr2tac.h:194

References BUFR2TAC_ERROR_STACK_DIM, bufr2tac_error::description, bufr2tac_error_stack::err, bufr2tac_error_stack::full, bufr2tac_error_stack::ne, and bufr2tac_error::severity.

Referenced by bufr2tac_set_error().

Here is the caller graph for this function:

◆ bufr2tac_set_error()

int bufr2tac_set_error ( struct bufr2tac_subset_state s,
int  severity,
char *  origin,
char *  explanation 
)

Definition at line 59 of file bufr2tac_error.c.

60{
61 char description[BUFR2TAC_ERROR_DESCRIPTION_LENGTH], *c;
62
63 c = description;
64 c += sprintf ( c, "%s: ", origin );
65 c += sprintf ( c, " Descriptor: %u %02u %03u: \"%s\"",s->a->desc.f, s->a->desc.x, s->a->desc.y, s->a->name );
66
68 {
69 c+= sprintf ( c, " = MISSING. " );
70 }
71 else
72 {
73 if ( s->a->cval[0] )
74 c += sprintf ( c, " = '%s'. ", s->a->cval );
75 else if ( s->a->desc.x == 2 )
76 c += sprintf ( c, " = '%s'. ", s->a->ctable );
77 else
78 c += sprintf ( c, " = %lf . ", s->a->val );
79 }
80
81 c += sprintf ( c, "%s", explanation );
82
83
84 return bufr2tac_push_error ( &s->e, severity, description );
85}
#define BUFR2TAC_ERROR_DESCRIPTION_LENGTH
set de dimension of member description of a struct bufr2tac_error
Definition: bufr2tac.h:199
int bufr2tac_push_error(struct bufr2tac_error_stack *e, int severity, char *description)
#define DESCRIPTOR_VALUE_MISSING
Bit mask for a missing value in a struct bufr_atom_data.
Definition: bufrdeco.h:140
struct bufr_atom_data * a
Definition: bufr2tac.h:249
struct bufr2tac_error_stack e
Definition: bufr2tac.h:248
uint32_t mask
Definition: bufrdeco.h:437
char name[BUFR_TABLEB_NAME_LENGTH]
Definition: bufrdeco.h:438
char ctable[BUFR_EXPLAINED_LENGTH]
Definition: bufrdeco.h:444
struct bufr_descriptor desc
Definition: bufrdeco.h:436
double val
Definition: bufrdeco.h:440
char cval[BUFR_CVAL_LENGTH]
Definition: bufrdeco.h:443

References bufr2tac_subset_state::a, BUFR2TAC_ERROR_DESCRIPTION_LENGTH, bufr2tac_push_error(), bufr_atom_data::ctable, bufr_atom_data::cval, bufr_atom_data::desc, DESCRIPTOR_VALUE_MISSING, bufr2tac_subset_state::e, bufr_descriptor::f, bufr_atom_data::mask, bufr_atom_data::name, bufr_atom_data::val, bufr_descriptor::x, and bufr_descriptor::y.

Referenced by buoy_parse_x01(), buoy_parse_x02(), buoy_parse_x04(), buoy_parse_x05(), buoy_parse_x06(), buoy_parse_x07(), buoy_parse_x08(), buoy_parse_x10(), buoy_parse_x11(), buoy_parse_x12(), buoy_parse_x13(), buoy_parse_x14(), buoy_parse_x20(), buoy_parse_x22(), buoy_parse_x31(), buoy_parse_x33(), climat_parse_x01(), climat_parse_x02(), climat_parse_x04(), climat_parse_x05(), climat_parse_x06(), climat_parse_x07(), climat_parse_x08(), climat_parse_x10(), climat_parse_x11(), climat_parse_x12(), climat_parse_x13(), climat_parse_x14(), syn_parse_x01(), syn_parse_x02(), syn_parse_x04(), syn_parse_x05(), syn_parse_x06(), syn_parse_x07(), syn_parse_x08(), syn_parse_x10(), syn_parse_x11(), syn_parse_x12(), syn_parse_x13(), syn_parse_x14(), syn_parse_x20(), syn_parse_x22(), syn_parse_x31(), temp_parse_x01(), temp_parse_x02(), temp_parse_x04(), temp_parse_x05(), temp_parse_x06(), temp_parse_x07(), temp_parse_x08(), temp_parse_x10(), temp_parse_x11(), temp_parse_x12(), temp_parse_x20(), temp_parse_x22(), temp_parse_x31(), and temp_parse_x33().

Here is the call graph for this function:
Here is the caller graph for this function: