mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Add identifiers to error messages
To ease the debug process
This commit is contained in:
@ -79,17 +79,17 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
|
||||
/* Detect extended ASCII characters */
|
||||
for (i = 0; i < src_len; i++) {
|
||||
if (source[i] >= 128) {
|
||||
strcpy(symbol->errtxt, "Extended ASCII characters are not supported by GS1");
|
||||
strcpy(symbol->errtxt, "Extended ASCII characters are not supported by GS1 (B50)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
if (source[i] < 32) {
|
||||
strcpy(symbol->errtxt, "Control characters are not supported by GS1");
|
||||
strcpy(symbol->errtxt, "Control characters are not supported by GS1 (B51)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (source[0] != '[') {
|
||||
strcpy(symbol->errtxt, "Data does not start with an AI");
|
||||
strcpy(symbol->errtxt, "Data does not start with an AI (B52)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -129,31 +129,31 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
|
||||
|
||||
if (bracket_level != 0) {
|
||||
/* Not all brackets are closed */
|
||||
strcpy(symbol->errtxt, "Malformed AI in input data (brackets don\'t match)");
|
||||
strcpy(symbol->errtxt, "Malformed AI in input data (brackets don\'t match) (B53)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (max_bracket_level > 1) {
|
||||
/* Nested brackets */
|
||||
strcpy(symbol->errtxt, "Found nested brackets in input data");
|
||||
strcpy(symbol->errtxt, "Found nested brackets in input data (B54)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (max_ai_length > 4) {
|
||||
/* AI is too long */
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (AI too long)");
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (AI too long) (B55)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (min_ai_length <= 1) {
|
||||
/* AI is too short */
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (AI too short)");
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (AI too short) (B56)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (ai_latch == 1) {
|
||||
/* Non-numeric data in AI */
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (non-numeric characters in AI)");
|
||||
strcpy(symbol->errtxt, "Invalid AI in input data (non-numeric characters in AI) (B57)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
|
||||
for (i = 0; i < ai_count; i++) {
|
||||
if (data_length[i] == 0) {
|
||||
/* No data for given AI */
|
||||
strcpy(symbol->errtxt, "Empty data field in input data");
|
||||
strcpy(symbol->errtxt, "Empty data field in input data (B58)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
}
|
||||
@ -286,13 +286,13 @@ int gs1_verify(struct zint_symbol *symbol, const unsigned char source[], const s
|
||||
}
|
||||
|
||||
if (error_latch == 5) {
|
||||
strcpy(symbol->errtxt, "Invalid data length for AI ");
|
||||
strcpy(symbol->errtxt, "Invalid data length for AI (B59)");
|
||||
strcat(symbol->errtxt, ai_string);
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (error_latch == 6) {
|
||||
strcpy(symbol->errtxt, "Invalid AI value ");
|
||||
strcpy(symbol->errtxt, "Invalid AI value (B60)");
|
||||
strcat(symbol->errtxt, ai_string);
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
@ -353,6 +353,6 @@ int ugs1_verify(struct zint_symbol *symbol, const unsigned char source[], const
|
||||
ustrcpy(reduced, (unsigned char*) temp);
|
||||
return 0;
|
||||
}
|
||||
strcpy(symbol->errtxt, "ugs1_verify overflow");
|
||||
strcpy(symbol->errtxt, "ugs1_verify overflow (B61)");
|
||||
return ZINT_ERROR_INVALID_DATA;
|
||||
}
|
||||
|
Reference in New Issue
Block a user