c-multihash/src/errors.c

28 lines
707 B
C
Raw Permalink Normal View History

2016-07-26 11:00:54 +00:00
#include "mh/errors.h"
2016-07-25 10:51:54 +00:00
2016-11-07 22:05:49 +00:00
/**
* Convert an error code into a string
* @param code the error code
* @returns the error as text
*/
const char *mh_error_string(int code) {
switch (code) {
case MH_E_NO_ERROR:
return "no error";
case MH_E_UNKNOWN_CODE:
return "unknown multihash code";
case MH_E_TOO_SHORT:
return "multihash too short. must be > 2 bytes";
case MH_E_TOO_LONG:
return "multihash too long. must be < 129 bytes";
case MH_E_VARINT_NOT_SUPPORTED:
return "c-multihash does not yet support"
" varint encoding";
case MH_E_DIGSET_TOO_LONG:
return "c-multihash does not support digsets"
" longer than 127 bytes yet";
default:
return "unknown error code";
2016-07-25 11:06:39 +00:00
}
2016-07-25 10:51:54 +00:00
}