Files
ropkg/libropkg/status.c
T

157 lines
4.2 KiB
C
Raw Normal View History

2026-06-22 17:45:54 +01:00
#include <fx/error.h>
2025-07-21 22:43:32 +01:00
#include <ropkg/status.h>
2026-06-22 17:45:54 +01:00
static const fx_error_definition ropkg_errors[] = {
FX_ERROR_DEFINITION(ROPKG_SUCCESS, "SUCCESS", "Success"),
FX_ERROR_DEFINITION(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_NOT_SUPPORTED,
"NOT_SUPPORTED",
"Operation not supported"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_INVALID_ARGUMENT,
"INVALID_ARGUMENT",
"Invalid argument"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(ROPKG_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
FX_ERROR_DEFINITION(ROPKG_ERR_BAD_STATE, "BAD_STATE", "Bad state"),
FX_ERROR_DEFINITION(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_INTERNAL_FAILURE,
"INTERNAL_FAILURE",
"Internal failure"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(ROPKG_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
FX_ERROR_DEFINITION(
ROPKG_ERR_NO_ENTRY,
"NO_ENTRY",
"Name does not exist"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(ROPKG_ERR_NO_DATA, "NO_DATA", "No data available"),
FX_ERROR_DEFINITION(
ROPKG_ERR_NAME_EXISTS,
"NAME_EXISTS",
"Name already exist"),
2025-07-21 22:43:32 +01:00
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION_TEMPLATE(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_DIR_OPEN_FAILED,
"DIR_OPEN_FAILED",
"Cannot open directory @i[filepath]",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"filepath",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s")),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
ROPKG_ERR_INSTANCE_LOCKED,
"INSTANCE_LOCKED",
"The Rosetta system root is locked. Another Rosetta package "
"management tool may be running."),
FX_ERROR_DEFINITION_TEMPLATE(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_INSTANCE_DIR_CREATE_FAILED,
"INSTANCE_DIR_CREATE_FAILED",
"Cannot create sub-directory @i[subdirpath] in instance "
"@i[instancepath]",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"instancepath",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s"),
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"subdirpath",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s")),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION_TEMPLATE(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_FILE_OPEN_FAILED,
"FILE_OPEN_FAILED",
"Cannot open file @i[filepath]",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"filepath",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s")),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
ROPKG_ERR_INVALID_MANIFEST_FORMAT,
"INVALID_MANIFSET_FORMAT",
"Invalid manifest format"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
2025-07-21 22:43:32 +01:00
ROPKG_ERR_INVALID_VERSION_FORMAT,
"INVALID_VERSION_FORMAT",
"Invalid version format"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
ROPKG_ERR_INVALID_PKG_EXPR,
"INVALID_PKG_EXPR",
"Invalid package expression"),
2026-06-22 17:45:54 +01:00
FX_ERROR_DEFINITION(
ROPKG_ERR_INVALID_PKG_FILE,
"INVALID_PKG_FILE",
"Invalid package file"),
FX_ERROR_DEFINITION(
ROPKG_ERR_DB_OP_FAILED,
"DB_OP_FAILED",
"Database operation failed"),
FX_ERROR_DEFINITION(
ROPKG_ERR_NO_CHANNEL,
"NO_CHANNEL",
"Channel does not exist"),
FX_ERROR_DEFINITION(
ROPKG_ERR_NO_COMPONENT,
"NO_COMPONENT",
"Component does not exist"),
2025-07-21 22:43:32 +01:00
};
2026-06-22 17:45:54 +01:00
static const fx_error_msg ropkg_error_msg[] = {
FX_ERROR_MSG_TEMPLATE(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_RELEASE_PHASE,
"@i[phase] is not a valid package release phase",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"phase",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s")),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_AVAILABLE_RELEASE_PHASES,
"valid release phases: @i{alpha}, @i{beta}"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_AVAILABLE_VERSION_RELEASE_PHASES,
"valid version release phases: @i{alpha}, @i{beta}, @i{rc}"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_UNKNOWN_START,
"unexpected character found while parsing upstream version"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_TWO_DOTS,
"two consecutive full stops found in upstream version"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_END_DOT,
"upstream version identifier cannot end with a full stop"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_TOO_MANY_NUMBERS,
"upstream version can contain no more than five number "
"components"),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG_TEMPLATE(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_VERSION_RELEASE_PHASE,
"@i[phase] is not a valid package version release phase",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM(
2025-07-21 22:43:32 +01:00
"phase",
2026-06-22 17:45:54 +01:00
FX_ERROR_TEMPLATE_PARAM_STRING,
2025-07-21 22:43:32 +01:00
"%s")),
2026-06-22 17:45:54 +01:00
FX_ERROR_MSG(
2025-07-21 22:43:32 +01:00
ROPKG_EMSG_INVALID_VERSION_UNKNOWN_END,
"unrecognised characters at the end of the version identifier"),
};
2026-06-22 17:45:54 +01:00
static const fx_error_vendor ropkg_error_vend = {
2025-07-21 22:43:32 +01:00
.v_name = "Ropkg",
.v_error_definitions = ropkg_errors,
.v_error_definitions_length = sizeof ropkg_errors,
.v_msg = ropkg_error_msg,
.v_msg_length = sizeof ropkg_error_msg,
};
2026-06-22 17:45:54 +01:00
const struct fx_error_vendor *ropkg_error_vendor(void)
2025-07-21 22:43:32 +01:00
{
return &ropkg_error_vend;
}