uriparser / uriparser

:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

Home Page:https://uriparser.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error codes and handling

veselov opened this issue · comments

commented

Cool library, first of all.
However, I was browsing through the documentation and the API documentation, and I can't seem to find:

  • exhaustive list of error codes that are defined
  • methods returning errors don't specify which error codes they may return
  • no strerror analogue

There are references to URI_ERROR_SYNTAX, but that's sort of stray.
Is there any ongoing work to address this?

Hi Pawel,

for the list of error codes:

# git grep -Eoh 'URI_ERROR_[A-Z_]+' | sort -u
URI_ERROR_ADDBASE_REL_BASE
URI_ERROR_MALLOC
URI_ERROR_MEMORY_MANAGER_FAULTY
URI_ERROR_MEMORY_MANAGER_INCOMPLETE
URI_ERROR_NOT_IMPLEMENTED
URI_ERROR_NULL
URI_ERROR_OUTPUT_TOO_LARGE
URI_ERROR_RANGE_INVALID
URI_ERROR_REMOVEBASE_REL_BASE
URI_ERROR_REMOVEBASE_REL_SOURCE
URI_ERROR_SYNTAX
URI_ERROR_TOSTRING_TOO_LONG

Also this, not the comments:

/* Shared errors */
#define URI_SUCCESS 0
#define URI_ERROR_SYNTAX 1 /* Parsed text violates expected format */
#define URI_ERROR_NULL 2 /* One of the params passed was NULL
although it mustn't be */
#define URI_ERROR_MALLOC 3 /* Requested memory could not be allocated */
#define URI_ERROR_OUTPUT_TOO_LARGE 4 /* Some output is to large for the receiving buffer */
#define URI_ERROR_NOT_IMPLEMENTED 8 /* The called function is not implemented yet */
#define URI_ERROR_RANGE_INVALID 9 /* The parameters passed contained invalid ranges */
#define URI_ERROR_MEMORY_MANAGER_INCOMPLETE 10 /* [>=0.9.0] The UriMemoryManager passed does not implement all needed functions */
/* Errors specific to ToString */
#define URI_ERROR_TOSTRING_TOO_LONG URI_ERROR_OUTPUT_TOO_LARGE /* Deprecated, test for URI_ERROR_OUTPUT_TOO_LARGE instead */
/* Errors specific to AddBaseUri */
#define URI_ERROR_ADDBASE_REL_BASE 5 /* Given base is not absolute */
/* Errors specific to RemoveBaseUri */
#define URI_ERROR_REMOVEBASE_REL_BASE 6 /* Given base is not absolute */
#define URI_ERROR_REMOVEBASE_REL_SOURCE 7 /* Given base is not absolute */
/* Error specific to uriTestMemoryManager */
#define URI_ERROR_MEMORY_MANAGER_FAULTY 11 /* [>=0.9.0] The UriMemoryManager given did not pass the test suite */

I'd be open to do more in that regard, but you're the first to ask since project birth and it's not a priority. Would welcome a clean pull request.

Regarding strerror: No plans and no need so far, would welcome a clean pull request.

URI_ERROR_SYNTAX is accompanied by the precise error position. Classification might be possible, but would be quite some work to get fully covered and may break ABI compatibility. Not a good cost benefit ratio so far.

Best, Sebastian

Question seems answered — I'll close the ticket. Happy to re-open as needed.