Wakaama is following the C pattern of returning a value that might be a success or failure, depending on the specific value or specific error ranges. The library is not consistent in its returns though. Sometimes COAP error codes are returned, sometimes just a -1 or a 0 means an error.
The C++ std::optional (C++11 backport, using C++17 native if available) should be used for returning a value instead. The alternative would be exceptions, but using these in the embedded domain is controversial and the code might be compiled with -fno-exceptions.
Wakaama is following the C pattern of returning a value that might be a success or failure, depending on the specific value or specific error ranges. The library is not consistent in its returns though. Sometimes COAP error codes are returned, sometimes just a -1 or a 0 means an error.
The C++ std::optional (C++11 backport, using C++17 native if available) should be used for returning a value instead. The alternative would be exceptions, but using these in the embedded domain is controversial and the code might be compiled with -fno-exceptions.
See https://github.com/martinmoene/optional-lite