Add function for getting error strings

Bug #989131 reported by Nicholas Humfrey
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
mosquitto
Fix Released
Wishlist
Unassigned

Bug Description

Please add a function to the client library, to get an error message string for an error number.

Something like:
const char* mosquitto_strerror(int mosq_errno)

It may also be preferable to put the error numbers into a enum, so that when using a switch statement, the compiler can check that you have implemented all the values.

Tags: wishlist
Revision history for this message
Roger Light (roger.light) wrote :

Sounds reasonable. Does using enums have any implication for ABI stability? I had a feeling #defines were better but I can't find anything that says enums will break binary compatibility if you add to them.

Changed in mosquitto:
importance: Undecided → Wishlist
milestone: none → 0.16
status: New → Confirmed
Revision history for this message
Roger Light (roger.light) wrote :

The function now exists but may need some string changes:

https://bitbucket.org/oojah/mosquitto/changeset/cca382120ddb

I'm still thinking about enums.

Changed in mosquitto:
status: Confirmed → In Progress
Revision history for this message
Nicholas Humfrey (njh-aelius) wrote :

It is pretty safe to use enums to define values.

Googling seems to imply that there are some potential ABI issues with using enums for parameters to functions and return types - their size isn't guaranteed on all platforms.

However it should be safe to cast them to/from an integer.

Changed in mosquitto:
milestone: 0.16 → 1.0
status: In Progress → Fix Committed
Changed in mosquitto:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.