Converts a given error code (errno) to a useful and human readable string.

    :param int code: a possibly invalid/unknown error code
    :rtype: str
    :returns: a string explaining and containing the given error code, or a string
              explaining that the errorcode is unknown if that is the case

def error_code_to_str(code):
    """
    Converts a given error code (errno) to a useful and human readable string.

    :param int code: a possibly invalid/unknown error code
    :rtype: str
    :returns: a string explaining and containing the given error code, or a string
              explaining that the errorcode is unknown if that is the case
    """

    try:
        name = errno.errorcode[code]
    except KeyError:
        name = "UNKNOWN"

    try:
        description = os.strerror(code)
    except ValueError:
        description = "no description available"

    return "{} (errno {}): {}".format(name, code, description)