/* SPDX-License-Identifier: GPL-2.0-only */

#include <ppm/error.h>

const char *ppm_strerror(ppm_error_t err) {
    switch (err) {
    case PPM_OK:                return "success";
    case PPM_ERR_NOMEM:         return "out of memory";
    case PPM_ERR_IO:            return "I/O error";
    case PPM_ERR_PARSE:         return "parse error";
    case PPM_ERR_INVALID:       return "invalid argument";
    case PPM_ERR_NOT_FOUND:     return "not found";
    case PPM_ERR_EXISTS:        return "already exists";
    case PPM_ERR_PERMISSION:    return "permission denied";
    case PPM_ERR_CONFLICT:      return "package conflict (one-version rule)";
    case PPM_ERR_UNSAT:         return "no satisfying version assignment";
    case PPM_ERR_HASH_MISMATCH: return "SHA-512 hash mismatch";
    case PPM_ERR_SIG_INVALID:   return "invalid Ed25519 signature";
    case PPM_ERR_NETWORK:       return "network error";
    case PPM_ERR_REGISTRY:      return "registry layout invalid";
    case PPM_ERR_TXN_ABORT:     return "transaction aborted";
    case PPM_ERR_UNSUPPORTED:   return "unsupported feature";
    case PPM_ERR_INTERNAL:      return "internal error (please report)";
    }
    return "unknown error";
}
