On 13 Mar 2015 08:55, "Daniel Stenberg" <daniel_at_haxx.se> wrote:
> On Thu, 12 Mar 2015, Will Cosgrove wrote:
>>> But they're different error codes, they're not in a single number range.
>> They are in a single range across the project, look at _FX_ and
_KNOWNHOST_ errors. For example:
>> LIBSSH2_KNOWNHOST_CHECK_MISMATCH 1
>> LIBSSH2_FX_EOF 1
>> These types of collisions are not great, IMHO.
> They are the same values because they actually are in different ranges.
But I also recognize that it isn't very ovious since the functions all just
return 'int' - which I think is unfortunate but really a design choice made
back in the days we still lived in caves.
> Changing them to different typedef'ed variables depending on what error
code range they return would be a good thing for a future API update.
>> we have a function like errorMessageFromCode(int code), the _code_ is
the code coming from any o’l libssh function call.
> But that's the mistake. All libssh2 functions don't return the same error
code set. The libssh2_knownhost*() functions for example only return error
codes in the LIBSSH2_KNOWNHOST_CHECK_* series.
If I may weigh in here, the known_host return codes aren't error codes at
all. That's where the misunderstanding has occurred.
Most libssh2 return codes are indeed errors. You can think of them as
exceptions, in a language that has that feature. Apart from EAGAIN, you
never call a libssh2 function expecting to recieve one of those errors.
Contrast that with the known_host functions. There the return code is a
result, not an error. You call those functions fully expecting to get any
of the possible values returned.
Received on 2015-03-13