@@ -267,8 +267,9 @@ union_find_type(const struct ly_ctx *ctx, struct lysc_type_union *type_u, struct
267
267
LY_ARRAY_COUNT_TYPE u ;
268
268
struct ly_err_item * * errs = NULL , * e ;
269
269
uint32_t * prev_lo , temp_lo = 0 ;
270
- char * msg = NULL ;
270
+ char * msg = NULL , * err_app_tag = NULL ;
271
271
int msg_len = 0 ;
272
+ ly_bool use_err_app_tag = 0 ;
272
273
273
274
* err = NULL ;
274
275
@@ -306,12 +307,27 @@ union_find_type(const struct ly_ctx *ctx, struct lysc_type_union *type_u, struct
306
307
continue ;
307
308
}
308
309
310
+ /* use an app-tag if all the types set it or set none */
311
+ if (errs [u ]-> apptag ) {
312
+ if (!err_app_tag ) {
313
+ err_app_tag = strdup (errs [u ]-> apptag );
314
+ LY_CHECK_ERR_GOTO (!err_app_tag , ret = LY_EMEM , cleanup );
315
+ use_err_app_tag = 1 ;
316
+ } else if (strcmp (errs [u ]-> apptag , err_app_tag )) {
317
+ use_err_app_tag = 0 ;
318
+ }
319
+ }
320
+
309
321
msg = ly_realloc (msg , msg_len + 4 + strlen (type_u -> types [u ]-> plugin -> id ) + 2 + strlen (errs [u ]-> msg ) + 2 );
310
322
LY_CHECK_ERR_GOTO (!msg , ret = LY_EMEM , cleanup );
311
323
msg_len += sprintf (msg + msg_len , " %s: %s\n" , type_u -> types [u ]-> plugin -> id , errs [u ]-> msg );
312
324
}
313
325
314
- ret = ly_err_new (err , LY_EVALID , LYVE_DATA , NULL , NULL , "%s" , msg );
326
+ if (!use_err_app_tag ) {
327
+ free (err_app_tag );
328
+ err_app_tag = NULL ;
329
+ }
330
+ ret = ly_err_new (err , LY_EVALID , LYVE_DATA , NULL , err_app_tag , "%s" , msg );
315
331
} else if (type_idx ) {
316
332
* type_idx = u ;
317
333
}
0 commit comments