aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2021-09-09 13:57:43 -0400
committerDavid Robillard <d@drobilla.net>2022-01-28 21:57:07 -0500
commitbd24b8f6d558bafbbb16d9490ebe3478dbf130bd (patch)
tree592c5ebc7694a80952b193de0adea0f4e640ec65
parent1fb84760a8230637a806e8e83410fc7fb6d446d2 (diff)
downloadserd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.tar.gz
serd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.tar.bz2
serd-bd24b8f6d558bafbbb16d9490ebe3478dbf130bd.zip
Use more human-readable status codes
-rw-r--r--include/serd/serd.h53
-rw-r--r--src/block_dumper.c4
-rw-r--r--src/byte_source.c2
-rw-r--r--src/canon.c2
-rw-r--r--src/cursor.c2
-rw-r--r--src/env.c6
-rw-r--r--src/env.h4
-rw-r--r--src/input_stream.c2
-rw-r--r--src/inserter.c2
-rw-r--r--src/log.c2
-rw-r--r--src/model.c4
-rw-r--r--src/n3.c85
-rw-r--r--src/node.c33
-rw-r--r--src/nodes.c4
-rw-r--r--src/output_stream.c2
-rw-r--r--src/read_ntriples.c75
-rw-r--r--src/read_utf8.c6
-rw-r--r--src/reader.c18
-rw-r--r--src/reader.h7
-rw-r--r--src/string.c59
-rw-r--r--src/writer.c27
-rw-r--r--test/test_env.c4
-rw-r--r--test/test_log.c2
-rw-r--r--test/test_model.c14
-rw-r--r--test/test_node.c2
-rw-r--r--test/test_overflow.c4
-rw-r--r--test/test_reader.c4
-rw-r--r--test/test_reader_writer.c4
-rw-r--r--test/test_sink.c4
-rw-r--r--test/test_string.c6
-rw-r--r--test/test_writer.c16
-rw-r--r--tools/console.c20
-rw-r--r--tools/serd-filter.c8
-rw-r--r--tools/serd-pipe.c2
-rw-r--r--tools/serd-sort.c4
35 files changed, 246 insertions, 247 deletions
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 9eb84a6a..b70500c1 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -217,24 +217,28 @@ serd_free(void* SERD_NULLABLE ptr);
/// Return status code
typedef enum {
- SERD_SUCCESS, ///< No error
- SERD_FAILURE, ///< Non-fatal failure
- SERD_ERR_UNKNOWN, ///< Unknown error
- SERD_ERR_BAD_SYNTAX, ///< Invalid syntax
- SERD_ERR_BAD_ARG, ///< Invalid argument
- SERD_ERR_BAD_CURSOR, ///< Use of invalidated cursor
- SERD_ERR_NOT_FOUND, ///< Not found
- SERD_ERR_ID_CLASH, ///< Encountered clashing blank node IDs
- SERD_ERR_BAD_CURIE, ///< Invalid CURIE or unknown namespace prefix
- SERD_ERR_INTERNAL, ///< Unexpected internal error
- SERD_ERR_OVERFLOW, ///< Stack overflow
- SERD_ERR_BAD_TEXT, ///< Invalid text encoding
- SERD_ERR_BAD_WRITE, ///< Error writing to file/stream
- SERD_ERR_NO_DATA, ///< Unexpected end of input
- SERD_ERR_BAD_CALL, ///< Invalid call
- SERD_ERR_BAD_URI, ///< Invalid or unresolved URI
- SERD_ERR_BAD_INDEX, ///< No optimal model index available
- SERD_ERR_INVALID, ///< Invalid data
+ SERD_SUCCESS, ///< Success
+ SERD_FAILURE, ///< Non-fatal failure
+ SERD_UNKNOWN_ERROR, ///< Unknown error
+ SERD_NO_DATA, ///< Missing input
+ SERD_OVERFLOW, ///< Insufficient space
+
+ SERD_BAD_ALLOC, ///< Memory allocation failed
+ SERD_BAD_ARG, ///< Invalid argument
+ SERD_BAD_CALL, ///< Invalid call
+ SERD_BAD_CURIE, ///< Invalid CURIE or unknown namespace prefix
+ SERD_BAD_CURSOR, ///< Use of invalidated cursor
+ SERD_BAD_EVENT, ///< Invalid event in stream
+ SERD_BAD_INDEX, ///< No optimal model index available
+ SERD_BAD_LABEL, ///< Encountered clashing blank node label
+ SERD_BAD_LITERAL, ///< Invalid literal
+ SERD_BAD_PATTERN, ///< Invalid statement pattern
+ SERD_BAD_READ, ///< Error reading from file
+ SERD_BAD_STACK, ///< Stack overflow
+ SERD_BAD_SYNTAX, ///< Invalid syntax
+ SERD_BAD_TEXT, ///< Invalid text encoding
+ SERD_BAD_URI, ///< Invalid or unresolved URI
+ SERD_BAD_WRITE, ///< Error writing to file
} SerdStatus;
/**
@@ -255,9 +259,8 @@ typedef struct {
/**
Number of bytes written or required.
- On success, this is the total number of bytes written. On
- #SERD_ERR_OVERFLOW, this is the number of bytes of output space that are
- required for success.
+ On success, this is the total number of bytes written. On #SERD_OVERFLOW,
+ this is the number of bytes of output space that are required for success.
*/
size_t count;
} SerdWriteResult;
@@ -674,8 +677,8 @@ typedef enum {
Otherwise, it is ignored.
@return A result with a `status` and a `count` of bytes written. If the
- buffer is too small for the node, then `status` will be #SERD_ERR_OVERFLOW,
- and `count` will be set to the number of bytes required to successfully
+ buffer is too small for the node, then `status` will be #SERD_OVERFLOW, and
+ `count` will be set to the number of bytes required to successfully
construct the node.
*/
SERD_API
@@ -1107,8 +1110,8 @@ serd_get_base64_size(const SerdNode* SERD_NONNULL node);
@param buf Buffer where decoded data will be written.
@return On success, #SERD_SUCCESS is returned along with the number of bytes
- written. If the output buffer is too small, then #SERD_ERR_OVERFLOW is
- returned along with the number of bytes required for successful decoding.
+ written. If the output buffer is too small, then #SERD_OVERFLOW is returned
+ along with the number of bytes required for successful decoding.
*/
SERD_API
SerdWriteResult
diff --git a/src/block_dumper.c b/src/block_dumper.c
index 6ffb0013..201b5dbf 100644
--- a/src/block_dumper.c
+++ b/src/block_dumper.c
@@ -27,7 +27,7 @@ serd_block_dumper_open(SerdBlockDumper* const dumper,
const size_t block_size)
{
if (!block_size) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
dumper->out = output;
@@ -40,7 +40,7 @@ serd_block_dumper_open(SerdBlockDumper* const dumper,
}
dumper->buf = (char*)serd_allocate_buffer(block_size);
- return dumper->buf ? SERD_SUCCESS : SERD_ERR_INTERNAL;
+ return dumper->buf ? SERD_SUCCESS : SERD_BAD_ALLOC;
}
void
diff --git a/src/byte_source.c b/src/byte_source.c
index 47753d83..396e16d0 100644
--- a/src/byte_source.c
+++ b/src/byte_source.c
@@ -44,7 +44,7 @@ serd_byte_source_page(SerdByteSource* const source)
buf[n_read] = '\0';
if (n_read == 0) {
source->eof = true;
- return (source->in->error(source->in->stream) ? SERD_ERR_UNKNOWN
+ return (source->in->error(source->in->stream) ? SERD_BAD_READ
: SERD_FAILURE);
}
}
diff --git a/src/canon.c b/src/canon.c
index 67cf30bf..ac0c91c2 100644
--- a/src/canon.c
+++ b/src/canon.c
@@ -151,7 +151,7 @@ serd_canon_on_statement(SerdCanonData* const data,
exess_strerror(r.status));
if (!lax) {
- return SERD_ERR_INVALID;
+ return SERD_BAD_LITERAL;
}
}
diff --git a/src/cursor.c b/src/cursor.c
index 650ac771..1a94142e 100644
--- a/src/cursor.c
+++ b/src/cursor.c
@@ -186,7 +186,7 @@ serd_cursor_advance(SerdCursor* const cursor)
assert(cursor);
if (zix_btree_iter_is_end(cursor->iter) || !check_version(cursor)) {
- return SERD_ERR_BAD_CURSOR;
+ return SERD_BAD_CURSOR;
}
const ZixStatus zst = zix_btree_iter_increment(&cursor->iter);
diff --git a/src/env.c b/src/env.c
index 0fd603a9..a6f1b5a9 100644
--- a/src/env.c
+++ b/src/env.c
@@ -206,7 +206,7 @@ serd_env_set_prefix(SerdEnv* const env,
}
if (!env->base_uri_node) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
// Resolve potentially relative URI reference to an absolute URI
@@ -260,13 +260,13 @@ serd_env_expand_in_place(const SerdEnv* const env,
const char* const colon =
str ? (const char*)memchr(str, ':', curie.len + 1) : NULL;
if (!colon) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
const size_t name_len = (size_t)(colon - str);
const SerdPrefix* const prefix = serd_env_find(env, str, name_len);
if (!prefix || !prefix->uri) {
- return SERD_ERR_BAD_CURIE;
+ return SERD_BAD_CURIE;
}
uri_prefix->buf = prefix->uri ? serd_node_string(prefix->uri) : "";
diff --git a/src/env.h b/src/env.h
index cafbeedc..764e036e 100644
--- a/src/env.h
+++ b/src/env.h
@@ -24,8 +24,8 @@
/**
Expand `curie`.
- Errors: SERD_ERR_BAD_ARG if `curie` is not valid, or SERD_ERR_BAD_CURIE if
- prefix is not defined in `env`.
+ Errors: SERD_BAD_ARG if `curie` is not valid, or SERD_BAD_CURIE if prefix is
+ not defined in `env`.
*/
SerdStatus
serd_env_expand_in_place(const SerdEnv* env,
diff --git a/src/input_stream.c b/src/input_stream.c
index 42dfc6f8..5755ccc3 100644
--- a/src/input_stream.c
+++ b/src/input_stream.c
@@ -146,5 +146,5 @@ serd_close_input(SerdInputStream* const input)
input->stream = NULL;
}
- return ret ? SERD_ERR_UNKNOWN : SERD_SUCCESS;
+ return ret ? SERD_BAD_READ : SERD_SUCCESS;
}
diff --git a/src/inserter.c b/src/inserter.c
index 100fc23a..96caf216 100644
--- a/src/inserter.c
+++ b/src/inserter.c
@@ -68,7 +68,7 @@ serd_inserter_on_statement(SerdInserterData* const data,
// Check that every node is expanded so it is context-free
for (unsigned i = 0; i < 4; ++i) {
if (!can_insert(world, serd_statement_node(statement, (SerdField)i))) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
}
diff --git a/src/log.c b/src/log.c
index 16c62860..dd62e5cc 100644
--- a/src/log.c
+++ b/src/log.c
@@ -129,7 +129,7 @@ serd_vxlogf(const SerdWorld* const world,
const int r = vsnprintf(message, sizeof(message), fmt, args);
return (r <= 0 || (size_t)r >= sizeof(message))
- ? SERD_ERR_BAD_ARG
+ ? SERD_BAD_ARG
: world->log_func(world->log_handle,
level,
n_fields,
diff --git a/src/model.c b/src/model.c
index e6033278..0cf3b842 100644
--- a/src/model.c
+++ b/src/model.c
@@ -100,7 +100,7 @@ serd_model_drop_index(SerdModel* const model, const SerdStatementOrder order)
}
if (order == model->default_order) {
- return SERD_ERR_BAD_CALL;
+ return SERD_BAD_CALL;
}
zix_btree_free(model->indices[order], NULL);
@@ -619,7 +619,7 @@ serd_model_add_with_caret(SerdModel* const model,
SerdStatement* const statement = serd_statement_new(s, p, o, g, NULL);
if (!statement) {
- return SERD_ERR_UNKNOWN;
+ return SERD_BAD_ALLOC;
}
statement->caret = serd_model_intern_caret(model, caret);
diff --git a/src/n3.c b/src/n3.c
index 3b12dfec..0ded004d 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -107,7 +107,7 @@ read_STRING_LITERAL_LONG(SerdReader* const reader,
return r_err(reader, st, "invalid escape `\\%c'", peek_byte(reader));
}
} else if (c == EOF) {
- st = r_err(reader, SERD_ERR_NO_DATA, "unexpected end of file");
+ st = r_err(reader, SERD_NO_DATA, "unexpected end of file");
} else if (c == q) {
eat_byte_safe(reader, q);
const int q2 = eat_byte_safe(reader, peek_byte(reader));
@@ -136,7 +136,7 @@ read_String(SerdReader* const reader, SerdNode* const node)
const int q2 = peek_byte(reader);
if (q2 == EOF) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "unexpected end of file");
+ return r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
}
if (q2 != q1) { // Short string (not triple quoted)
@@ -146,7 +146,7 @@ read_String(SerdReader* const reader, SerdNode* const node)
eat_byte_safe(reader, q2);
const int q3 = peek_byte(reader);
if (q3 == EOF) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "unexpected end of file");
+ return r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
}
if (q3 != q1) { // Empty short string ("" or '')
@@ -171,7 +171,7 @@ read_PERCENT(SerdReader* const reader, SerdNode* const dest)
const uint8_t h1 = read_HEX(reader);
const uint8_t h2 = read_HEX(reader);
if (!h1 || !h2) {
- return SERD_ERR_BAD_SYNTAX;
+ return SERD_BAD_SYNTAX;
}
if (!(st = push_byte(reader, dest, h1))) {
@@ -188,9 +188,8 @@ read_PN_LOCAL_ESC(SerdReader* const reader, SerdNode* const dest)
const int c = peek_byte(reader);
- return is_PN_LOCAL_ESC(c)
- ? push_byte(reader, dest, eat_byte_safe(reader, c))
- : r_err(reader, SERD_ERR_BAD_SYNTAX, "invalid escape");
+ return is_PN_LOCAL_ESC(c) ? push_byte(reader, dest, eat_byte_safe(reader, c))
+ : r_err(reader, SERD_BAD_SYNTAX, "invalid escape");
}
static SerdStatus
@@ -277,7 +276,7 @@ read_PN_PREFIX_tail(SerdReader* const reader, SerdNode* const dest)
serd_node_string(dest)[serd_node_length(dest) - 1] == '.') {
if ((st = read_PN_CHARS(reader, dest))) {
return r_err(reader,
- st > SERD_FAILURE ? st : SERD_ERR_BAD_SYNTAX,
+ st > SERD_FAILURE ? st : SERD_BAD_SYNTAX,
"prefix ends with `.'");
}
}
@@ -332,7 +331,7 @@ resolve_IRIREF(SerdReader* const reader,
uri = serd_resolve_uri(uri, serd_env_base_uri_view(reader->env));
if (!uri.scheme.len) {
return r_err(reader,
- SERD_ERR_BAD_SYNTAX,
+ SERD_BAD_SYNTAX,
"failed to resolve relative URI reference <%s>",
serd_node_string(dest));
}
@@ -340,7 +339,7 @@ resolve_IRIREF(SerdReader* const reader,
// Push a new temporary node for constructing the resolved URI
SerdNode* const temp = push_node(reader, SERD_URI, "", 0);
if (!temp) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
// Write resolved URI to the temporary node
@@ -364,7 +363,7 @@ read_IRIREF(SerdReader* const reader, SerdNode** const dest)
}
if (!(*dest = push_node(reader, SERD_URI, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
const size_t string_start_offset = reader->stack.size;
@@ -438,7 +437,7 @@ read_0_9(SerdReader* const reader, SerdNode* const str, const bool at_least_one)
}
if (at_least_one && count == 0) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected digit");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected digit");
}
return st;
@@ -459,7 +458,7 @@ read_number(SerdReader* const reader,
int c = peek_byte(reader);
bool has_decimal = false;
if (!*dest) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
if (c == '-' || c == '+') {
@@ -523,7 +522,7 @@ read_iri(SerdReader* const reader, SerdNode** const dest, bool* const ate_dot)
}
if (!(*dest = push_node(reader, SERD_LITERAL, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
return read_PrefixedName(reader, *dest, true, ate_dot, reader->stack.size);
@@ -535,7 +534,7 @@ read_literal(SerdReader* const reader,
bool* const ate_dot)
{
if (!(*dest = push_node(reader, SERD_LITERAL, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
SerdStatus st = read_String(reader, *dest);
@@ -577,7 +576,7 @@ read_verb(SerdReader* reader, SerdNode** dest)
"a", produce that instead.
*/
if (!(*dest = push_node(reader, SERD_URI, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
const size_t string_start_offset = reader->stack.size;
@@ -594,7 +593,7 @@ read_verb(SerdReader* reader, SerdNode** dest)
serd_stack_pop_to(&reader->stack, orig_stack_size);
return ((*dest = push_node(reader, SERD_URI, NS_RDF "type", 47))
? SERD_SUCCESS
- : SERD_ERR_OVERFLOW);
+ : SERD_BAD_STACK);
}
if ((st = read_PrefixedName(
@@ -602,7 +601,7 @@ read_verb(SerdReader* reader, SerdNode** dest)
ate_dot) {
*dest = NULL;
return r_err(
- reader, st > SERD_FAILURE ? st : SERD_ERR_BAD_SYNTAX, "expected verb");
+ reader, st > SERD_FAILURE ? st : SERD_BAD_SYNTAX, "expected verb");
}
return SERD_SUCCESS;
@@ -627,7 +626,7 @@ read_anon(SerdReader* const reader,
if (!*dest) {
if (!(*dest = blank_id(reader))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
}
@@ -644,7 +643,7 @@ read_anon(SerdReader* const reader,
TRY(st, read_predicateObjectList(reader, ctx, &ate_dot_in_list));
if (ate_dot_in_list) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "`.' inside blank");
+ return r_err(reader, SERD_BAD_SYNTAX, "`.' inside blank");
}
read_ws_star(reader);
@@ -683,7 +682,7 @@ read_named_object(SerdReader* const reader,
out to actually be "true" or "false", switch it to a boolean literal. */
if (!(*dest = push_node(reader, SERD_URI, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
SerdNode* node = *dest;
@@ -699,12 +698,12 @@ read_named_object(SerdReader* const reader,
node->type = SERD_LITERAL;
return push_node(reader, SERD_URI, XSD_BOOLEAN, XSD_BOOLEAN_LEN)
? SERD_SUCCESS
- : SERD_ERR_OVERFLOW;
+ : SERD_BAD_STACK;
}
// Any other failure is a syntax error
if (st) {
- st = st > SERD_FAILURE ? st : SERD_ERR_BAD_SYNTAX;
+ st = st > SERD_FAILURE ? st : SERD_BAD_SYNTAX;
return r_err(reader, st, "expected prefixed name or boolean");
}
@@ -730,7 +729,7 @@ read_object(SerdReader* const reader,
switch (c) {
case EOF:
case ')':
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected object");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected object");
case '$':
case '?':
st = read_Var(reader, &o);
@@ -823,7 +822,7 @@ read_predicateObjectList(SerdReader* const reader,
switch (c = peek_byte(reader)) {
case EOF:
serd_stack_pop_to(&reader->stack, orig_stack_size);
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "unexpected end of file");
+ return r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
case '.':
case ']':
case '}':
@@ -837,7 +836,7 @@ read_predicateObjectList(SerdReader* const reader,
if (!ate_semi) {
serd_stack_pop_to(&reader->stack, orig_stack_size);
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "missing ';' or '.'");
+ return r_err(reader, SERD_BAD_SYNTAX, "missing ';' or '.'");
}
}
@@ -863,7 +862,7 @@ read_collection(SerdReader* const reader,
*dest = end ? reader->rdf_nil : blank_id(reader);
if (!*dest) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
if (ctx.subject) { // Reading a collection object
@@ -887,7 +886,7 @@ read_collection(SerdReader* const reader,
SerdNode* rest = 0;
if (!n1) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
ctx.subject = *dest;
@@ -951,7 +950,7 @@ read_subject(SerdReader* const reader,
}
if (ate_dot) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "subject ends with `.'");
+ return r_err(reader, SERD_BAD_SYNTAX, "subject ends with `.'");
}
return st;
@@ -971,14 +970,14 @@ read_labelOrSubject(SerdReader* const reader, SerdNode** const dest)
return st;
}
*dest = blank_id(reader);
- return *dest ? SERD_SUCCESS : SERD_ERR_OVERFLOW;
+ return *dest ? SERD_SUCCESS : SERD_BAD_STACK;
case '_':
return read_BLANK_NODE_LABEL(reader, dest, &ate_dot);
default:
if (!read_iri(reader, dest, &ate_dot)) {
return SERD_SUCCESS;
} else {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected label or subject");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected label or subject");
}
}
}
@@ -1017,7 +1016,7 @@ read_base(SerdReader* const reader, const bool sparql, const bool token)
TRY(st, read_IRIREF(reader, &uri));
if (reader->stack.size + sizeof(SerdNode) > reader->stack.buf_size) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
serd_node_zero_pad(uri);
@@ -1030,7 +1029,7 @@ read_base(SerdReader* const reader, const bool sparql, const bool token)
}
if (peek_byte(reader) == '.') {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "full stop after SPARQL BASE");
+ return r_err(reader, SERD_BAD_SYNTAX, "full stop after SPARQL BASE");
}
return SERD_SUCCESS;
@@ -1047,7 +1046,7 @@ read_prefixID(SerdReader* const reader, const bool sparql, const bool token)
read_ws_star(reader);
SerdNode* name = push_node(reader, SERD_LITERAL, "", 0);
if (!name) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
if ((st = read_PN_PREFIX(reader, name)) > SERD_FAILURE) {
@@ -1063,7 +1062,7 @@ read_prefixID(SerdReader* const reader, const bool sparql, const bool token)
TRY(st, read_IRIREF(reader, &uri));
if (reader->stack.size + sizeof(SerdNode) > reader->stack.buf_size) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
serd_node_zero_pad(name);
@@ -1103,8 +1102,7 @@ read_wrappedGraph(SerdReader* const reader, ReadContext* const ctx)
}
if (read_triples(reader, *ctx, &ate_dot) && s_type != '[') {
- return r_err(
- reader, SERD_ERR_BAD_SYNTAX, "missing predicate object list");
+ return r_err(reader, SERD_BAD_SYNTAX, "missing predicate object list");
}
serd_stack_pop_to(&reader->stack, orig_stack_size);
@@ -1118,7 +1116,7 @@ read_wrappedGraph(SerdReader* const reader, ReadContext* const ctx)
eat_byte_safe(reader, '}');
read_ws_star(reader);
if (peek_byte(reader) == '.') {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "graph followed by `.'");
+ return r_err(reader, SERD_BAD_SYNTAX, "graph followed by `.'");
}
return SERD_SUCCESS;
@@ -1146,7 +1144,7 @@ read_turtle_directive(SerdReader* const reader)
break;
}
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected \"base\" or \"prefix\"");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected \"base\" or \"prefix\"");
}
static SerdStatus
@@ -1194,7 +1192,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
read_ws_star(reader);
if (peek_byte(reader) == '{') {
if (s_type == '(' || (s_type == '[' && !*ctx->flags)) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "invalid graph name");
+ return r_err(reader, SERD_BAD_SYNTAX, "invalid graph name");
}
ctx->graph = token;
@@ -1203,7 +1201,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
}
if (st) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected directive or subject");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected directive or subject");
}
// Our token is really a subject, read some triples
@@ -1215,7 +1213,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
// "Failure" is only allowed for anonymous subjects like "[ ... ] ."
if (st && s_type != '[') {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected triples");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected triples");
}
// Ensure that triples are properly terminated
@@ -1244,8 +1242,7 @@ read_n3_statement(SerdReader* const reader)
case '{':
return (reader->syntax == SERD_TRIG)
? read_wrappedGraph(reader, &ctx)
- : r_err(
- reader, SERD_ERR_BAD_SYNTAX, "syntax does not support graphs");
+ : r_err(reader, SERD_BAD_SYNTAX, "syntax does not support graphs");
default:
break;
diff --git a/src/node.c b/src/node.c
index 550fa732..61a45a03 100644
--- a/src/node.c
+++ b/src/node.c
@@ -93,9 +93,8 @@ serd_node_malloc(const size_t size)
SerdNode*
serd_node_try_malloc(const SerdWriteResult r)
{
- return (r.status && r.status != SERD_ERR_OVERFLOW)
- ? NULL
- : serd_node_malloc(r.count);
+ return (r.status && r.status != SERD_OVERFLOW) ? NULL
+ : serd_node_malloc(r.count);
}
void
@@ -153,7 +152,7 @@ serd_node_construct_simple(const size_t buf_size,
{
const size_t total_size = sizeof(SerdNode) + serd_node_pad_length(string.len);
if (!buf || total_size > buf_size) {
- return result(SERD_ERR_OVERFLOW, total_size);
+ return result(SERD_OVERFLOW, total_size);
}
SerdNode* const node = (SerdNode*)buf;
@@ -221,18 +220,18 @@ serd_node_construct_literal(const size_t buf_size,
}
if ((flags & SERD_HAS_DATATYPE) && (flags & SERD_HAS_LANGUAGE)) {
- return result(SERD_ERR_BAD_ARG, 0);
+ return result(SERD_BAD_ARG, 0);
}
if (!meta.len) {
- return result(SERD_ERR_BAD_ARG, 0);
+ return result(SERD_BAD_ARG, 0);
}
if (((flags & SERD_HAS_DATATYPE) &&
(!serd_uri_string_has_scheme(meta.buf) ||
!strcmp(meta.buf, NS_RDF "langString"))) ||
((flags & SERD_HAS_LANGUAGE) && !is_langtag(meta))) {
- return result(SERD_ERR_BAD_ARG, 0);
+ return result(SERD_BAD_ARG, 0);
}
const size_t padded_length = serd_node_pad_length(string.len);
@@ -240,7 +239,7 @@ serd_node_construct_literal(const size_t buf_size,
const size_t meta_size = sizeof(SerdNode) + serd_node_pad_length(meta.len);
const size_t total_size = sizeof(SerdNode) + padded_length + meta_size;
if (!buf || total_size > buf_size) {
- return result(SERD_ERR_OVERFLOW, total_size);
+ return result(SERD_OVERFLOW, total_size);
}
SerdNode* const node = (SerdNode*)buf;
@@ -271,7 +270,7 @@ serd_node_construct(const size_t buf_size,
return ((type == SERD_LITERAL)
? serd_node_construct_literal(buf_size, buf, string, flags, meta)
: (meta.len > 0u)
- ? result(SERD_ERR_BAD_ARG, 0)
+ ? result(SERD_BAD_ARG, 0)
: serd_node_construct_token(buf_size, buf, type, string));
}
@@ -350,7 +349,7 @@ serd_node_construct_integer(const size_t buf_size,
const SerdStringView datatype)
{
if (datatype.len && !serd_uri_string_has_scheme(datatype.buf)) {
- return result(SERD_ERR_BAD_ARG, 0);
+ return result(SERD_BAD_ARG, 0);
}
char temp[24] = {0};
@@ -378,7 +377,7 @@ serd_node_construct_base64(const size_t buf_size,
// Verify argument sanity
if (!value || !value_size ||
(datatype.len && !serd_uri_string_has_scheme(datatype.buf))) {
- return result(SERD_ERR_BAD_ARG, 0);
+ return result(SERD_BAD_ARG, 0);
}
// Determine the type to use (default to xsd:base64Binary)
@@ -393,7 +392,7 @@ serd_node_construct_base64(const size_t buf_size,
const size_t padded_length = serd_node_pad_length(r.count);
const size_t total_size = sizeof(SerdNode) + padded_length + type_size;
if (!buf || total_size > buf_size) {
- return result(SERD_ERR_OVERFLOW, total_size);
+ return result(SERD_OVERFLOW, total_size);
}
SerdNode* const node = (SerdNode*)buf;
@@ -438,7 +437,7 @@ serd_node_construct_uri(const size_t buf_size,
const size_t length = serd_uri_string_length(uri);
const size_t required_size = sizeof(SerdNode) + serd_node_pad_length(length);
if (!buf || buf_size < required_size) {
- return result(SERD_ERR_OVERFLOW, required_size);
+ return result(SERD_OVERFLOW, required_size);
}
// Write node header
@@ -464,7 +463,7 @@ serd_node_new(const SerdNodeType type,
const SerdStringView meta)
{
SerdWriteResult r = serd_node_construct(0, NULL, type, string, flags, meta);
- if (r.status != SERD_ERR_OVERFLOW) {
+ if (r.status != SERD_OVERFLOW) {
return NULL;
}
@@ -602,8 +601,8 @@ serd_get_base64(const SerdNode* const node,
const ExessVariableResult r =
exess_read_base64(buf_size, buf, serd_node_string(node));
- return r.status == EXESS_NO_SPACE ? result(SERD_ERR_OVERFLOW, max_size)
- : r.status ? result(SERD_ERR_BAD_SYNTAX, 0u)
+ return r.status == EXESS_NO_SPACE ? result(SERD_OVERFLOW, max_size)
+ : r.status ? result(SERD_BAD_SYNTAX, 0u)
: result(SERD_SUCCESS, r.write_count);
}
@@ -749,7 +748,7 @@ serd_node_construct_file_uri(const size_t buf_size,
}
if (!buf || count > buf_size) {
- return result(SERD_ERR_OVERFLOW, count);
+ return result(SERD_OVERFLOW, count);
}
node->length = length;
diff --git a/src/nodes.c b/src/nodes.c
index 5c6492e4..b821c004 100644
--- a/src/nodes.c
+++ b/src/nodes.c
@@ -352,7 +352,7 @@ serd_nodes_literal(SerdNodes* const nodes,
// We need to insert a new entry, so determine how much space the node needs
SerdWriteResult r = serd_node_construct_literal(0, NULL, string, flags, meta);
- if (r.status != SERD_ERR_OVERFLOW) {
+ if (r.status != SERD_OVERFLOW) {
return NULL;
}
@@ -487,7 +487,7 @@ serd_nodes_parsed_uri(SerdNodes* const nodes, const SerdURIView uri)
// Determine how much space the node needs
SerdWriteResult r = serd_node_construct_uri(0u, NULL, uri);
- assert(r.status == SERD_ERR_OVERFLOW); // Currently no other errors
+ assert(r.status == SERD_OVERFLOW); // Currently no other errors
// Allocate a new entry to write the URI node into
NodesEntry* const entry = new_entry(r.count);
diff --git a/src/output_stream.c b/src/output_stream.c
index 1254aa4f..7beb5e2f 100644
--- a/src/output_stream.c
+++ b/src/output_stream.c
@@ -85,5 +85,5 @@ serd_close_output(SerdOutputStream* const output)
output->stream = NULL;
}
- return ret ? SERD_ERR_UNKNOWN : SERD_SUCCESS;
+ return ret ? SERD_BAD_WRITE : SERD_SUCCESS;
}
diff --git a/src/read_ntriples.c b/src/read_ntriples.c
index c107207d..64c823f6 100644
--- a/src/read_ntriples.c
+++ b/src/read_ntriples.c
@@ -43,12 +43,12 @@ SerdStatus
read_LANGTAG(SerdReader* const reader)
{
if (!is_alpha(peek_byte(reader))) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected A-Z or a-z");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected A-Z or a-z");
}
SerdNode* const node = push_node(reader, SERD_LITERAL, "", 0);
if (!node) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
// First component must be all letters
@@ -80,7 +80,7 @@ SerdStatus
read_EOL(SerdReader* const reader)
{
if (!is_EOL(peek_byte(reader))) {
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected a line ending");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected a line ending");
}
while (is_EOL(peek_byte(reader))) {
@@ -95,10 +95,8 @@ read_IRI_scheme(SerdReader* const reader, SerdNode* const dest)
{
int c = peek_byte(reader);
if (!is_alpha(c)) {
- return r_err(reader,
- SERD_ERR_BAD_SYNTAX,
- "'%c' is not a valid first IRI character",
- c);
+ return r_err(
+ reader, SERD_BAD_SYNTAX, "'%c' is not a valid first IRI character", c);
}
SerdStatus st = SERD_SUCCESS;
@@ -110,12 +108,12 @@ read_IRI_scheme(SerdReader* const reader, SerdNode* const dest)
st = is_uri_scheme_char(c)
? push_byte(reader, dest, eat_byte_safe(reader, c))
: r_err(reader,
- SERD_ERR_BAD_SYNTAX,
+ SERD_BAD_SYNTAX,
"U+%04X is not a valid IRI scheme character",
(unsigned)c);
}
- return st ? st : SERD_ERR_BAD_SYNTAX;
+ return st ? st : SERD_BAD_SYNTAX;
}
SerdStatus
@@ -128,7 +126,7 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
const int c = eat_byte(reader);
switch (c) {
case EOF:
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "unexpected end of file");
+ return r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
case ' ':
case '"':
@@ -139,7 +137,7 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
case '|':
case '}':
return r_err(
- reader, SERD_ERR_BAD_SYNTAX, "'%c' is not a valid IRI character", c);
+ reader, SERD_BAD_SYNTAX, "'%c' is not a valid IRI character", c);
case '>':
return SERD_SUCCESS;
@@ -150,10 +148,8 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
}
if (!code || code == ' ' || code == '<' || code == '>') {
- return r_err(reader,
- SERD_ERR_BAD_SYNTAX,
- "U+%04X is not a valid IRI character",
- code);
+ return r_err(
+ reader, SERD_BAD_SYNTAX, "U+%04X is not a valid IRI character", code);
}
break;
@@ -161,7 +157,7 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
default:
if (c <= 0x20) {
st = r_err(reader,
- SERD_ERR_BAD_SYNTAX,
+ SERD_BAD_SYNTAX,
"control character U+%04X is not a valid IRI character",
(uint32_t)c);
@@ -193,7 +189,7 @@ read_IRI(SerdReader* const reader, SerdNode** const dest)
eat_byte(reader);
if (!(*dest = push_node(reader, SERD_URI, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
SerdStatus st = SERD_SUCCESS;
@@ -225,10 +221,10 @@ read_STRING_LITERAL(SerdReader* const reader,
uint32_t code = 0;
switch (c) {
case EOF:
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "end of file in short string");
+ return r_err(reader, SERD_BAD_SYNTAX, "end of file in short string");
case '\n':
case '\r':
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "line end in short string");
+ return r_err(reader, SERD_BAD_SYNTAX, "line end in short string");
case '\\':
eat_byte_safe(reader, c);
if ((st = read_ECHAR(reader, ref)) &&
@@ -266,7 +262,7 @@ adjust_blank_id(SerdReader* const reader, char* const buf)
} else if (tag == 'B' && reader->seen_genid) {
// We've seen both b123 and B123 styles, abort due to possible clashes
return r_err(reader,
- SERD_ERR_ID_CLASH,
+ SERD_BAD_LABEL,
"found both `b' and `B' blank IDs, prefix required");
}
}
@@ -289,7 +285,7 @@ read_BLANK_NODE_LABEL(SerdReader* const reader,
if (!(*dest = push_node(
reader, SERD_BLANK, reader->bprefix, reader->bprefix_len))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
// Read first: (PN_CHARS_U | [0-9])
@@ -376,7 +372,7 @@ read_UCHAR(SerdReader* const reader,
length = 4;
break;
default:
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected 'U' or 'u'");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected 'U' or 'u'");
}
eat_byte_safe(reader, b);
@@ -384,7 +380,7 @@ read_UCHAR(SerdReader* const reader,
uint8_t buf[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
for (unsigned i = 0; i < length; ++i) {
if (!(buf[i] = read_HEX(reader))) {
- return SERD_ERR_BAD_SYNTAX;
+ return SERD_BAD_SYNTAX;
}
}
@@ -396,7 +392,7 @@ read_UCHAR(SerdReader* const reader,
if (!size) {
*code_point = 0xFFFD;
return (reader->strict
- ? r_err(reader, SERD_ERR_BAD_SYNTAX, "U+%X is out of range", code)
+ ? r_err(reader, SERD_BAD_SYNTAX, "U+%X is out of range", code)
: push_bytes(reader, node, replacement_char, 3));
}
@@ -430,7 +426,7 @@ read_ECHAR(SerdReader* const reader, SerdNode* const dest)
case '\'':
return push_byte(reader, dest, eat_byte_safe(reader, c));
default:
- return SERD_ERR_BAD_SYNTAX;
+ return SERD_BAD_SYNTAX;
}
}
@@ -455,12 +451,10 @@ read_PN_CHARS_BASE(SerdReader* const reader, SerdNode* const dest)
}
if (!is_PN_CHARS_BASE((int)code)) {
- r_err(reader,
- SERD_ERR_BAD_SYNTAX,
- "U+%04X is not a valid name character",
- code);
+ r_err(
+ reader, SERD_BAD_SYNTAX, "U+%04X is not a valid name character", code);
if (reader->strict) {
- return SERD_ERR_BAD_SYNTAX;
+ return SERD_BAD_SYNTAX;
}
}
@@ -492,7 +486,7 @@ read_PN_CHARS(SerdReader* const reader, SerdNode* const dest)
SerdStatus st = SERD_SUCCESS;
if (c == EOF) {
- return SERD_ERR_NO_DATA;
+ return SERD_NO_DATA;
}
if (is_alpha(c) || is_digit(c) || c == '_' || c == '-') {
@@ -511,10 +505,8 @@ read_PN_CHARS(SerdReader* const reader, SerdNode* const dest)
if (!is_PN_CHARS_BASE((int)code) && code != 0xB7 &&
!(code >= 0x0300 && code <= 0x036F) &&
!(code >= 0x203F && code <= 0x2040)) {
- return r_err(reader,
- SERD_ERR_BAD_SYNTAX,
- "U+%04X is not a valid name character",
- code);
+ return r_err(
+ reader, SERD_BAD_SYNTAX, "U+%04X is not a valid name character", code);
}
return st;
@@ -529,7 +521,7 @@ read_HEX(SerdReader* const reader)
return (uint8_t)eat_byte_safe(reader, c);
}
- r_err(reader, SERD_ERR_BAD_SYNTAX, "invalid hexadecimal digit `%c'", c);
+ r_err(reader, SERD_BAD_SYNTAX, "invalid hexadecimal digit `%c'", c);
return 0;
}
@@ -559,12 +551,11 @@ read_Var(SerdReader* const reader, SerdNode** const dest)
assert(peek_byte(reader) == '$' || peek_byte(reader) == '?');
if (!(reader->flags & SERD_READ_VARIABLES)) {
- return r_err(
- reader, SERD_ERR_BAD_SYNTAX, "syntax does not support variables");
+ return r_err(reader, SERD_BAD_SYNTAX, "syntax does not support variables");
}
if (!(*dest = push_node(reader, SERD_VARIABLE, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
serd_byte_source_advance(reader->source);
@@ -595,7 +586,7 @@ read_literal(SerdReader* const reader, SerdNode** const dest)
SerdStatus st = SERD_SUCCESS;
if (!(*dest = push_node(reader, SERD_LITERAL, "", 0))) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
eat_byte_safe(reader, '"');
@@ -642,7 +633,7 @@ read_nt_subject(SerdReader* const reader, SerdNode** const dest)
break;
}
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected '<' or '_'");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected '<' or '_'");
}
/// [4] predicate
@@ -675,7 +666,7 @@ read_nt_object(SerdReader* const reader,
return read_BLANK_NODE_LABEL(reader, dest, ate_dot);
default:
- return r_err(reader, SERD_ERR_BAD_SYNTAX, "expected '<', '_', or '\"'");
+ return r_err(reader, SERD_BAD_SYNTAX, "expected '<', '_', or '\"'");
}
}
diff --git a/src/read_utf8.c b/src/read_utf8.c
index 614ea14f..34d800cb 100644
--- a/src/read_utf8.c
+++ b/src/read_utf8.c
@@ -29,13 +29,13 @@ skip_invalid_utf8(SerdReader* const reader)
b = peek_byte(reader);
}
- return reader->strict ? SERD_ERR_BAD_SYNTAX : SERD_FAILURE;
+ return reader->strict ? SERD_BAD_SYNTAX : SERD_FAILURE;
}
static SerdStatus
bad_char(SerdReader* const reader, const char* const fmt, const uint8_t c)
{
- r_err(reader, SERD_ERR_BAD_SYNTAX, fmt, c);
+ r_err(reader, SERD_BAD_SYNTAX, fmt, c);
return skip_invalid_utf8(reader);
}
@@ -55,7 +55,7 @@ read_utf8_continuation_bytes(SerdReader* const reader,
for (uint32_t i = 1u; i < *size; ++i) {
const int b = peek_byte(reader);
if (b == EOF) {
- return r_err(reader, SERD_ERR_NO_DATA, "unexpected end of input");
+ return r_err(reader, SERD_NO_DATA, "unexpected end of input");
}
const uint8_t byte = (uint8_t)b;
diff --git a/src/reader.c b/src/reader.c
index d051c34a..985a9fd2 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -90,9 +90,9 @@ tolerate_status(const SerdReader* const reader, const SerdStatus status)
return true;
}
- if (status == SERD_ERR_INTERNAL || status == SERD_ERR_OVERFLOW ||
- status == SERD_ERR_BAD_WRITE || status == SERD_ERR_NO_DATA ||
- status == SERD_ERR_BAD_CALL || status == SERD_ERR_BAD_CURSOR) {
+ if (status == SERD_BAD_STACK || status == SERD_BAD_WRITE ||
+ status == SERD_NO_DATA || status == SERD_BAD_CALL ||
+ status == SERD_BAD_CURSOR) {
return false;
}
@@ -161,7 +161,7 @@ emit_statement_at(SerdReader* const reader,
SerdCaret* const caret)
{
if (reader->stack.size + (2 * sizeof(SerdNode)) > reader->stack.buf_size) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
/* Zero the pad of the object node on the top of the stack. Lower nodes
@@ -198,7 +198,7 @@ serd_reader_read_document(SerdReader* const reader)
assert(reader);
if (!reader->source) {
- return SERD_ERR_BAD_CALL;
+ return SERD_BAD_CALL;
}
if (!(reader->flags & SERD_READ_GLOBAL)) {
@@ -301,8 +301,8 @@ skip_bom(SerdReader* const me)
serd_byte_source_advance(me->source) ||
serd_byte_source_peek(me->source) != 0xBF ||
serd_byte_source_advance(me->source)) {
- r_err(me, SERD_ERR_BAD_SYNTAX, "corrupt byte order mark");
- return SERD_ERR_BAD_SYNTAX;
+ r_err(me, SERD_BAD_SYNTAX, "corrupt byte order mark");
+ return SERD_BAD_SYNTAX;
}
}
@@ -322,7 +322,7 @@ serd_reader_start(SerdReader* const reader,
reader->source = serd_byte_source_new_input(input, input_name, block_size);
- return reader->source ? SERD_SUCCESS : SERD_ERR_BAD_ARG;
+ return reader->source ? SERD_SUCCESS : SERD_BAD_ARG;
}
static SerdStatus
@@ -344,7 +344,7 @@ serd_reader_read_chunk(SerdReader* const reader)
SerdStatus st = SERD_SUCCESS;
if (!reader->source) {
- return SERD_ERR_BAD_CALL;
+ return SERD_BAD_CALL;
}
if (!reader->source->prepared) {
diff --git a/src/reader.h b/src/reader.h
index ecf420f4..a001d843 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -146,8 +146,7 @@ eat_byte_check(SerdReader* reader, const int byte)
{
const int c = peek_byte(reader);
if (c != byte) {
- return r_err(
- reader, SERD_ERR_BAD_SYNTAX, "expected `%c', not `%c'", byte, c);
+ return r_err(reader, SERD_BAD_SYNTAX, "expected `%c', not `%c'", byte, c);
}
eat_byte_safe(reader, byte);
@@ -174,7 +173,7 @@ push_byte(SerdReader* reader, SerdNode* node, const int c)
assert(c != EOF);
if (reader->stack.size + 1 > reader->stack.buf_size) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
((uint8_t*)reader->stack.buf)[reader->stack.size - 1] = (uint8_t)c;
@@ -194,7 +193,7 @@ push_bytes(SerdReader* reader, SerdNode* ref, const uint8_t* bytes, size_t len)
}
}
- return has_space ? SERD_SUCCESS : SERD_ERR_OVERFLOW;
+ return has_space ? SERD_SUCCESS : SERD_BAD_STACK;
}
#endif // SERD_READER_H
diff --git a/src/string.c b/src/string.c
index b9885d4f..136cb09c 100644
--- a/src/string.c
+++ b/src/string.c
@@ -35,38 +35,45 @@ serd_strerror(const SerdStatus status)
return "Success";
case SERD_FAILURE:
return "Non-fatal failure";
- case SERD_ERR_UNKNOWN:
+ case SERD_NO_DATA:
+ return "Unexpected end of input";
+ case SERD_UNKNOWN_ERROR:
break;
- case SERD_ERR_BAD_SYNTAX:
- return "Invalid syntax";
- case SERD_ERR_BAD_ARG:
+ case SERD_OVERFLOW:
+ return "Insufficient space";
+
+ case SERD_BAD_ALLOC:
+ return "Memory allocation failed";
+ case SERD_BAD_ARG:
return "Invalid argument";
- case SERD_ERR_BAD_CURSOR:
- return "Invalid cursor";
- case SERD_ERR_NOT_FOUND:
- return "Not found";
- case SERD_ERR_ID_CLASH:
- return "Blank node ID clash";
- case SERD_ERR_BAD_CURIE:
+ case SERD_BAD_CALL:
+ return "Invalid call";
+ case SERD_BAD_CURIE:
return "Invalid CURIE or unknown namespace prefix";
- case SERD_ERR_INTERNAL:
- return "Internal error";
- case SERD_ERR_OVERFLOW:
+ case SERD_BAD_CURSOR:
+ return "Invalid cursor";
+ case SERD_BAD_EVENT:
+ return "Invalid event in stream";
+ case SERD_BAD_INDEX:
+ return "No optimal model index available";
+ case SERD_BAD_LABEL:
+ return "Clashing blank node label";
+ case SERD_BAD_LITERAL:
+ return "Invalid literal";
+ case SERD_BAD_PATTERN:
+ return "Invalid statement pattern";
+ case SERD_BAD_READ:
+ return "Error reading from file";
+ case SERD_BAD_STACK:
return "Stack overflow";
- case SERD_ERR_BAD_TEXT:
+ case SERD_BAD_SYNTAX:
+ return "Invalid syntax";
+ case SERD_BAD_TEXT:
return "Invalid text encoding";
- case SERD_ERR_BAD_WRITE:
- return "Error writing to file";
- case SERD_ERR_NO_DATA:
- return "Unexpected end of input";
- case SERD_ERR_BAD_CALL:
- return "Invalid call";
- case SERD_ERR_BAD_URI:
+ case SERD_BAD_URI:
return "Invalid or unresolved URI";
- case SERD_ERR_BAD_INDEX:
- return "No optimal model index available";
- case SERD_ERR_INVALID:
- return "Invalid data";
+ case SERD_BAD_WRITE:
+ return "Error writing to file";
}
return "Unknown error";
diff --git a/src/writer.c b/src/writer.c
index 7cb28d0a..e19518e4 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -191,7 +191,7 @@ push_context(SerdWriter* const writer,
const SerdNode* const p)
{
if (writer->anon_stack_size >= anon_stack_capacity) {
- return SERD_ERR_OVERFLOW;
+ return SERD_BAD_STACK;
}
const WriteContext new_context = {type,
@@ -258,10 +258,10 @@ sink(const void* buf, size_t len, SerdWriter* writer)
char message[1024] = {0};
serd_system_strerror(errno, message, sizeof(message));
- w_err(writer, SERD_ERR_BAD_WRITE, "write error (%s)", message);
+ w_err(writer, SERD_BAD_WRITE, "write error (%s)", message);
} else {
w_err(writer,
- SERD_ERR_BAD_WRITE,
+ SERD_BAD_WRITE,
"unknown write error, %zu / %zu bytes written",
written,
len);
@@ -274,7 +274,7 @@ sink(const void* buf, size_t len, SerdWriter* writer)
SERD_WARN_UNUSED_RESULT static SerdStatus
esink(const void* buf, size_t len, SerdWriter* writer)
{
- return sink(buf, len, writer) == len ? SERD_SUCCESS : SERD_ERR_BAD_WRITE;
+ return sink(buf, len, writer) == len ? SERD_SUCCESS : SERD_BAD_WRITE;
}
// Write a single character as a Unicode escape
@@ -289,8 +289,7 @@ write_character(SerdWriter* writer,
const uint32_t c = parse_utf8_char(utf8, size);
switch (*size) {
case 0:
- w_err(writer, SERD_ERR_BAD_TEXT, "invalid UTF-8 start: %X", utf8[0]);
- *st = SERD_ERR_BAD_TEXT;
+ *st = w_err(writer, SERD_BAD_TEXT, "invalid UTF-8 start: %X", utf8[0]);
return 0;
case 1:
snprintf(escape, sizeof(escape), "\\u%04X", utf8[0]);
@@ -349,7 +348,7 @@ write_uri(SerdWriter* writer, const char* utf8, size_t n_bytes, SerdStatus* st)
const size_t n_bulk = sink(&utf8[i], j - i, writer);
len += n_bulk;
if (n_bulk != j - i) {
- *st = SERD_ERR_BAD_WRITE;
+ *st = SERD_BAD_WRITE;
return len;
}
@@ -384,7 +383,7 @@ ewrite_uri(SerdWriter* writer, const char* utf8, size_t n_bytes)
SerdStatus st = SERD_SUCCESS;
write_uri(writer, utf8, n_bytes, &st);
- return (st == SERD_ERR_BAD_WRITE || !(writer->flags & SERD_WRITE_LAX))
+ return (st == SERD_BAD_WRITE || !(writer->flags & SERD_WRITE_LAX))
? st
: SERD_SUCCESS;
}
@@ -862,7 +861,7 @@ write_uri_node(SerdWriter* const writer,
if (!has_scheme && !supports_uriref(writer) &&
!serd_env_base_uri(writer->env)) {
return w_err(writer,
- SERD_ERR_BAD_ARG,
+ SERD_BAD_ARG,
"syntax does not support URI reference <%s>",
node_str);
}
@@ -1211,7 +1210,7 @@ serd_writer_write_statement(SerdWriter* const writer,
((flags & SERD_ANON_O) && (flags & SERD_LIST_O)) || // Nonsense
((flags & SERD_ANON_S) && (flags & SERD_TERSE_S)) || // Unsupported
((flags & SERD_ANON_O) && (flags & SERD_TERSE_O))) { // Unsupported
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
switch (writer->syntax) {
@@ -1245,7 +1244,7 @@ serd_writer_end_anon(SerdWriter* writer, const SerdNode* node)
if (writer->anon_stack_size == 0) {
return w_err(writer,
- SERD_ERR_BAD_CALL,
+ SERD_BAD_EVENT,
"unexpected end of anonymous node `%s'",
serd_node_string(node));
}
@@ -1278,7 +1277,7 @@ serd_writer_on_event(SerdWriter* writer, const SerdEvent* event)
return serd_writer_end_anon(writer, event->end.node);
}
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
SerdStatus
@@ -1361,7 +1360,7 @@ serd_writer_set_base_uri(SerdWriter* writer, const SerdNode* uri)
assert(writer);
if (uri->type != SERD_URI) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
SerdStatus st = SERD_SUCCESS;
@@ -1405,7 +1404,7 @@ serd_writer_set_prefix(SerdWriter* writer,
const SerdNode* uri)
{
if (name->type != SERD_LITERAL || uri->type != SERD_URI) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
SerdStatus st = SERD_SUCCESS;
diff --git a/test/test_env.c b/test/test_env.c
index 58455167..3b6e20c9 100644
--- a/test/test_env.c
+++ b/test/test_env.c
@@ -99,7 +99,7 @@ test_base_uri(void)
// Try setting a relative prefix with no base URI
assert(serd_env_set_prefix(env, SERD_STRING("eg.3"), SERD_STRING("rel")) ==
- SERD_ERR_BAD_ARG);
+ SERD_BAD_ARG);
// Set a valid base URI
assert(!serd_env_set_base_uri(env, serd_node_string_view(eg)));
@@ -128,7 +128,7 @@ test_set_prefix(void)
assert(!serd_env_set_prefix(env, name1, eg));
// Test setting a prefix from a relative URI
- assert(serd_env_set_prefix(env, name2, rel) == SERD_ERR_BAD_ARG);
+ assert(serd_env_set_prefix(env, name2, rel) == SERD_BAD_ARG);
assert(!serd_env_set_base_uri(env, base));
assert(!serd_env_set_prefix(env, name2, rel));
diff --git a/test/test_log.c b/test/test_log.c
index 88d14dc6..707a00f2 100644
--- a/test/test_log.c
+++ b/test/test_log.c
@@ -52,7 +52,7 @@ test_bad_arg(void)
serd_set_log_func(world, custom_log_func, &called);
- assert(serd_logf(world, SERD_LOG_LEVEL_ERROR, "%s", "") == SERD_ERR_BAD_ARG);
+ assert(serd_logf(world, SERD_LOG_LEVEL_ERROR, "%s", "") == SERD_BAD_ARG);
serd_world_free(world);
}
diff --git a/test/test_model.c b/test/test_model.c
index 78372997..3e781c7e 100644
--- a/test/test_model.c
+++ b/test/test_model.c
@@ -164,7 +164,7 @@ test_read(SerdWorld* world,
}
// Attempt to increment past end
- assert(serd_cursor_advance(cursor) == SERD_ERR_BAD_CURSOR);
+ assert(serd_cursor_advance(cursor) == SERD_BAD_CURSOR);
serd_cursor_free(cursor);
const SerdStringView s = SERD_STRING("hello");
@@ -453,7 +453,7 @@ test_add_with_iterator(SerdWorld* world, const unsigned n_quads)
// Check that iterator has been invalidated
assert(!serd_cursor_get(iter));
- assert(serd_cursor_advance(iter) == SERD_ERR_BAD_CURSOR);
+ assert(serd_cursor_advance(iter) == SERD_BAD_CURSOR);
serd_cursor_free(iter);
serd_model_free(model);
@@ -543,7 +543,7 @@ test_remove_index(SerdWorld* world, const unsigned n_quads)
const SerdNode* const o2 = uri(world, 3);
// Try to remove default and non-existent indices
- assert(serd_model_drop_index(model, SERD_ORDER_SPO) == SERD_ERR_BAD_CALL);
+ assert(serd_model_drop_index(model, SERD_ORDER_SPO) == SERD_BAD_CALL);
assert(serd_model_drop_index(model, SERD_ORDER_PSO) == SERD_FAILURE);
// Add a couple of statements so that dropping an index isn't trivial
@@ -578,7 +578,7 @@ test_inserter(SerdWorld* world, const unsigned n_quads)
serd_set_log_func(world, expected_error, NULL);
- assert(serd_sink_write(inserter, 0, s, p, rel, NULL) == SERD_ERR_BAD_ARG);
+ assert(serd_sink_write(inserter, 0, s, p, rel, NULL) == SERD_BAD_ARG);
serd_sink_free(inserter);
serd_model_free(model);
@@ -612,7 +612,7 @@ test_erase_with_iterator(SerdWorld* world, const unsigned n_quads)
// Check that other iterator has been invalidated
assert(!serd_cursor_get(iter2));
- assert(serd_cursor_advance(iter2) == SERD_ERR_BAD_CURSOR);
+ assert(serd_cursor_advance(iter2) == SERD_BAD_CURSOR);
// Check that erasing the end iterator does nothing
SerdCursor* const end = serd_cursor_copy(serd_model_end(model));
@@ -1290,7 +1290,7 @@ test_write_error_in_list_subject(SerdWorld* world, const unsigned n_quads)
const SerdStatus st = serd_describe_range(all, sink, 0);
serd_cursor_free(all);
- assert(st == SERD_ERR_BAD_WRITE);
+ assert(st == SERD_BAD_WRITE);
serd_writer_free(writer);
serd_close_output(&out);
@@ -1346,7 +1346,7 @@ test_write_error_in_list_object(SerdWorld* world, const unsigned n_quads)
const SerdStatus st = serd_describe_range(all, sink, 0);
serd_cursor_free(all);
- assert(st == SERD_ERR_BAD_WRITE);
+ assert(st == SERD_BAD_WRITE);
serd_writer_free(writer);
serd_close_output(&out);
diff --git a/test/test_node.c b/test/test_node.c
index 200791af..41ee6209 100644
--- a/test/test_node.c
+++ b/test/test_node.c
@@ -408,7 +408,7 @@ test_get_base64(void)
char small[2] = {0};
const SerdWriteResult r = serd_get_base64(node, sizeof(small), small);
- assert(r.status == SERD_ERR_OVERFLOW);
+ assert(r.status == SERD_OVERFLOW);
serd_node_free(node);
}
diff --git a/test/test_overflow.c b/test/test_overflow.c
index ca273b23..2aedc1bb 100644
--- a/test/test_overflow.c
+++ b/test/test_overflow.c
@@ -67,11 +67,11 @@ test_all_sizes(SerdWorld* const world,
// Test with an increasingly smaller stack
for (size_t size = max_stack_size; size > min_stack_size; --size) {
if ((st = test_size(world, str, syntax, flags, size))) {
- assert(st == SERD_ERR_OVERFLOW);
+ assert(st == SERD_BAD_STACK);
}
}
- assert(st == SERD_ERR_OVERFLOW);
+ assert(st == SERD_BAD_STACK);
}
static void
diff --git a/test/test_reader.c b/test/test_reader.c
index 1c28e3da..37e645e3 100644
--- a/test/test_reader.c
+++ b/test/test_reader.c
@@ -74,12 +74,12 @@ test_prepare_error(void)
SerdInputStream in =
serd_open_input_stream(prepare_test_read, prepare_test_error, NULL, f);
- assert(serd_reader_start(reader, &in, NULL, 0) == SERD_ERR_BAD_ARG);
+ assert(serd_reader_start(reader, &in, NULL, 0) == SERD_BAD_ARG);
SerdStatus st = serd_reader_start(reader, &in, NULL, 1);
assert(!st);
- assert(serd_reader_read_document(reader) == SERD_ERR_UNKNOWN);
+ assert(serd_reader_read_document(reader) == SERD_BAD_READ);
serd_close_input(&in);
serd_reader_free(reader);
diff --git a/test/test_reader_writer.c b/test/test_reader_writer.c
index 82af9f20..8bb76083 100644
--- a/test/test_reader_writer.c
+++ b/test/test_reader_writer.c
@@ -146,8 +146,8 @@ test_reader(const char* path)
SerdReader* reader = serd_reader_new(world, SERD_TURTLE, 0u, env, sink, 4096);
assert(reader);
- assert(serd_reader_read_document(reader) == SERD_ERR_BAD_CALL);
- assert(serd_reader_read_chunk(reader) == SERD_ERR_BAD_CALL);
+ assert(serd_reader_read_document(reader) == SERD_BAD_CALL);
+ assert(serd_reader_read_chunk(reader) == SERD_BAD_CALL);
SerdInputStream in = serd_open_input_file(path);
assert(!serd_reader_start(reader, &in, NULL, 4096));
diff --git a/test/test_sink.c b/test/test_sink.c
index 29bb793f..8bbfbb2d 100644
--- a/test/test_sink.c
+++ b/test/test_sink.c
@@ -91,7 +91,7 @@ on_event(void* const handle, const SerdEvent* const event)
return on_end(handle, event->end.node);
}
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
static void
@@ -157,7 +157,7 @@ test_callbacks(void)
assert(serd_node_equals(state.last_end, blank));
const SerdEvent junk = {(SerdEventType)42};
- assert(serd_sink_write_event(sink, &junk) == SERD_ERR_BAD_ARG);
+ assert(serd_sink_write_event(sink, &junk) == SERD_BAD_ARG);
serd_sink_free(sink);
diff --git a/test/test_string.c b/test/test_string.c
index f8534001..c91284bb 100644
--- a/test/test_string.c
+++ b/test/test_string.c
@@ -32,13 +32,17 @@ test_strerror(void)
{
const char* msg = serd_strerror(SERD_SUCCESS);
assert(!strcmp(msg, "Success"));
- for (int i = SERD_FAILURE; i <= SERD_ERR_INVALID; ++i) {
+
+ for (int i = SERD_FAILURE; i <= SERD_BAD_WRITE; ++i) {
msg = serd_strerror((SerdStatus)i);
assert(strcmp(msg, "Success"));
}
msg = serd_strerror((SerdStatus)-1);
assert(!strcmp(msg, "Unknown error"));
+
+ msg = serd_strerror((SerdStatus)1000000);
+ assert(!strcmp(msg, "Unknown error"));
}
static void
diff --git a/test/test_writer.c b/test/test_writer.c
index 34eafbb2..c719642f 100644
--- a/test/test_writer.c
+++ b/test/test_writer.c
@@ -52,7 +52,7 @@ test_write_bad_event(void)
const SerdEvent event = {(SerdEventType)42};
assert(serd_sink_write_event(serd_writer_sink(writer), &event) ==
- SERD_ERR_BAD_ARG);
+ SERD_BAD_ARG);
assert(!serd_close_output(&output));
@@ -158,12 +158,12 @@ test_writer_stack_overflow(void)
o = next_o;
if (st) {
- assert(st == SERD_ERR_OVERFLOW);
+ assert(st == SERD_BAD_STACK);
break;
}
}
- assert(st == SERD_ERR_OVERFLOW);
+ assert(st == SERD_BAD_STACK);
serd_writer_free(writer);
serd_close_output(&output);
@@ -199,8 +199,8 @@ test_strict_write(void)
const SerdNode* bad_lit = serd_nodes_string(nodes, bad_view);
const SerdNode* bad_uri = serd_nodes_uri(nodes, bad_view);
- assert(serd_sink_write(sink, 0, s, p, bad_lit, 0) == SERD_ERR_BAD_TEXT);
- assert(serd_sink_write(sink, 0, s, p, bad_uri, 0) == SERD_ERR_BAD_TEXT);
+ assert(serd_sink_write(sink, 0, s, p, bad_lit, 0) == SERD_BAD_TEXT);
+ assert(serd_sink_write(sink, 0, s, p, bad_uri, 0) == SERD_BAD_TEXT);
serd_writer_free(writer);
serd_close_output(&output);
@@ -250,7 +250,7 @@ test_write_error(void)
assert(writer);
SerdStatus st = serd_sink_write(serd_writer_sink(writer), 0u, s, p, o, NULL);
- assert(st == SERD_ERR_BAD_WRITE);
+ assert(st == SERD_BAD_WRITE);
serd_writer_free(writer);
serd_close_output(&output);
@@ -262,7 +262,7 @@ test_write_error(void)
assert(writer);
assert(serd_sink_write(serd_writer_sink(writer), 0u, s, p, o, NULL) ==
- SERD_ERR_BAD_WRITE);
+ SERD_BAD_WRITE);
serd_writer_free(writer);
serd_close_output(&output);
@@ -337,7 +337,7 @@ test_write_bad_uri(void)
serd_sink_write(serd_writer_sink(writer), 0u, s, p, rel, NULL);
assert(st);
- assert(st == SERD_ERR_BAD_ARG);
+ assert(st == SERD_BAD_ARG);
serd_close_output(&output);
serd_free(buffer.buf);
diff --git a/tools/console.c b/tools/console.c
index ab36364d..0e41a2a0 100644
--- a/tools/console.c
+++ b/tools/console.c
@@ -45,7 +45,7 @@ serd_tool_setup(SerdTool* const tool,
"%s: failed to open output file (%s)\n",
program,
strerror(errno));
- return SERD_ERR_UNKNOWN;
+ return SERD_UNKNOWN_ERROR;
}
// We have something to write to, so build the writing environment
@@ -61,7 +61,7 @@ serd_tool_setup(SerdTool* const tool,
&tool->out,
options.block_size))) {
fprintf(stderr, "%s: failed to set up writing environment\n", program);
- return SERD_ERR_INTERNAL;
+ return SERD_UNKNOWN_ERROR;
}
return SERD_SUCCESS;
@@ -75,7 +75,7 @@ serd_tool_cleanup(SerdTool tool)
// Close the output stream explicitly to check if there were any errors
if (serd_close_output(&tool.out)) {
perror("write error");
- st = SERD_ERR_BAD_WRITE;
+ st = SERD_BAD_WRITE;
}
}
@@ -120,7 +120,7 @@ serd_get_argument(OptionIter* const iter, const char** const argument)
if (iter->argv[iter->a][iter->f] || (iter->a + 1) == iter->argc) {
fprintf(
stderr, "%s: option requires an argument -- %c\n", iter->argv[0], flag);
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
*argument = iter->argv[++iter->a];
@@ -141,7 +141,7 @@ serd_get_size_argument(OptionIter* const iter, size_t* const argument)
char* endptr = NULL;
const long size = strtol(string, &endptr, 10);
if (size <= 0 || size == LONG_MAX || *endptr != '\0') {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
*argument = (size_t)size;
@@ -181,7 +181,7 @@ serd_set_input_option(const SerdStringView name,
}
}
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
SerdStatus
@@ -238,7 +238,7 @@ serd_set_output_option(const SerdStringView name,
}
}
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
SerdStatus
@@ -384,12 +384,12 @@ serd_set_base_uri_from_path(SerdEnv* const env, const char* const path)
{
const size_t path_len = path ? strlen(path) : 0u;
if (!path_len) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
char* const real_path = serd_canonical_path(path);
if (!real_path) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
const size_t real_path_len = strlen(real_path);
@@ -455,7 +455,7 @@ serd_read_inputs(SerdWorld* const world,
// Open the input stream
SerdInputStream in = serd_open_tool_input(in_path);
if (!in.stream) {
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
// Read the entire file
diff --git a/tools/serd-filter.c b/tools/serd-filter.c
index ed22373c..0804d6ba 100644
--- a/tools/serd-filter.c
+++ b/tools/serd-filter.c
@@ -51,7 +51,7 @@ on_pattern_event(void* const handle, const SerdEvent* const event)
if (event->type == SERD_STATEMENT) {
FilterPattern* const pat = (FilterPattern*)handle;
if (pat->s) {
- return SERD_ERR_INVALID;
+ return SERD_BAD_PATTERN;
}
const SerdStatement* const statement = event->statement.statement;
@@ -149,7 +149,7 @@ run(Options opts)
if (!pattern.stream) {
log_error(app.world, "failed to open pattern");
- return SERD_ERR_UNKNOWN;
+ return SERD_UNKNOWN_ERROR;
}
// Set up the output pipeline: filter -> writer
@@ -157,7 +157,7 @@ run(Options opts)
parse_pattern(app.world, target, &pattern, !opts.invert);
if (!filter) {
log_error(app.world, "failed to set up filter");
- return SERD_ERR_UNKNOWN;
+ return SERD_UNKNOWN_ERROR;
}
serd_close_input(&pattern);
@@ -245,7 +245,7 @@ parse_option(OptionIter* const iter, Options* const opts)
}
ARG_ERRORF("invalid option -- '%c'\n", opt);
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
#undef ARG_ERRORF
}
diff --git a/tools/serd-pipe.c b/tools/serd-pipe.c
index 879a56b5..f2891f9b 100644
--- a/tools/serd-pipe.c
+++ b/tools/serd-pipe.c
@@ -163,7 +163,7 @@ parse_option(OptionIter* const iter, Options* const opts)
}
ARG_ERRORF("invalid option -- '%c'\n", opt);
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
#undef ARG_ERRORF
}
diff --git a/tools/serd-sort.c b/tools/serd-sort.c
index 1018350d..7219fa26 100644
--- a/tools/serd-sort.c
+++ b/tools/serd-sort.c
@@ -162,7 +162,7 @@ parse_statement_order(const char* const string, SerdStatementOrder* const order)
}
}
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
}
static int
@@ -237,7 +237,7 @@ parse_option(OptionIter* const iter, Options* const opts)
}
ARG_ERRORF("invalid option -- '%c'\n", opt);
- return SERD_ERR_BAD_ARG;
+ return SERD_BAD_ARG;
#undef ARG_ERRORF
}