2025-07-21 22:43:32 +01:00
|
|
|
#include <blue/core/error.h>
|
|
|
|
|
#include <ropkg/status.h>
|
|
|
|
|
|
|
|
|
|
static const b_error_definition ropkg_errors[] = {
|
|
|
|
|
B_ERROR_DEFINITION(ROPKG_SUCCESS, "SUCCESS", "Success"),
|
|
|
|
|
B_ERROR_DEFINITION(
|
|
|
|
|
ROPKG_ERR_NOT_SUPPORTED,
|
|
|
|
|
"NOT_SUPPORTED",
|
|
|
|
|
"Operation not supported"),
|
|
|
|
|
B_ERROR_DEFINITION(
|
|
|
|
|
ROPKG_ERR_INVALID_ARGUMENT,
|
|
|
|
|
"INVALID_ARGUMENT",
|
|
|
|
|
"Invalid argument"),
|
|
|
|
|
B_ERROR_DEFINITION(ROPKG_ERR_NO_MEMORY, "NO_MEMORY", "Out of memory"),
|
|
|
|
|
B_ERROR_DEFINITION(ROPKG_ERR_BAD_STATE, "BAD_STATE", "Bad state"),
|
|
|
|
|
B_ERROR_DEFINITION(
|
|
|
|
|
ROPKG_ERR_INTERNAL_FAILURE,
|
|
|
|
|
"INTERNAL_FAILURE",
|
|
|
|
|
"Internal failure"),
|
|
|
|
|
B_ERROR_DEFINITION(ROPKG_ERR_IO_FAILURE, "IO_FAILURE", "I/O failure"),
|
|
|
|
|
|
|
|
|
|
B_ERROR_DEFINITION_TEMPLATE(
|
|
|
|
|
ROPKG_ERR_DIR_OPEN_FAILED,
|
|
|
|
|
"DIR_OPEN_FAILED",
|
|
|
|
|
"Cannot open directory @i[filepath]",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"filepath",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s")),
|
|
|
|
|
|
|
|
|
|
B_ERROR_DEFINITION_TEMPLATE(
|
|
|
|
|
ROPKG_ERR_INSTANCE_DIR_CREATE_FAILED,
|
|
|
|
|
"INSTANCE_DIR_CREATE_FAILED",
|
|
|
|
|
"Cannot create sub-directory @i[subdirpath] in instance "
|
|
|
|
|
"@i[instancepath]",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"instancepath",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s"),
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"subdirpath",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s")),
|
|
|
|
|
|
|
|
|
|
B_ERROR_DEFINITION_TEMPLATE(
|
|
|
|
|
ROPKG_ERR_FILE_OPEN_FAILED,
|
|
|
|
|
"FILE_OPEN_FAILED",
|
|
|
|
|
"Cannot open file @i[filepath]",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"filepath",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s")),
|
|
|
|
|
|
|
|
|
|
B_ERROR_DEFINITION(
|
|
|
|
|
ROPKG_ERR_INVALID_VERSION_FORMAT,
|
|
|
|
|
"INVALID_VERSION_FORMAT",
|
|
|
|
|
"Invalid version format"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const b_error_msg ropkg_error_msg[] = {
|
|
|
|
|
B_ERROR_MSG_TEMPLATE(
|
|
|
|
|
ROPKG_EMSG_INVALID_RELEASE_PHASE,
|
|
|
|
|
"@i[phase] is not a valid package release phase",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"phase",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s")),
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_AVAILABLE_RELEASE_PHASES,
|
|
|
|
|
"valid release phases: @i{alpha}, @i{beta}"),
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_AVAILABLE_VERSION_RELEASE_PHASES,
|
|
|
|
|
"valid version release phases: @i{alpha}, @i{beta}, @i{rc}"),
|
|
|
|
|
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_UNKNOWN_START,
|
|
|
|
|
"unexpected character found while parsing upstream version"),
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_TWO_DOTS,
|
|
|
|
|
"two consecutive full stops found in upstream version"),
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_END_DOT,
|
|
|
|
|
"upstream version identifier cannot end with a full stop"),
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_INVALID_UPSTREAM_VERSION_TOO_MANY_NUMBERS,
|
|
|
|
|
"upstream version can contain no more than five number "
|
|
|
|
|
"components"),
|
|
|
|
|
|
|
|
|
|
B_ERROR_MSG_TEMPLATE(
|
|
|
|
|
ROPKG_EMSG_INVALID_VERSION_RELEASE_PHASE,
|
|
|
|
|
"@i[phase] is not a valid package version release phase",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM(
|
|
|
|
|
"phase",
|
|
|
|
|
B_ERROR_TEMPLATE_PARAM_STRING,
|
|
|
|
|
"%s")),
|
|
|
|
|
|
|
|
|
|
B_ERROR_MSG(
|
|
|
|
|
ROPKG_EMSG_INVALID_VERSION_UNKNOWN_END,
|
|
|
|
|
"unrecognised characters at the end of the version identifier"),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const b_error_vendor ropkg_error_vend = {
|
|
|
|
|
.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,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const struct b_error_vendor *ropkg_error_vendor(void)
|
|
|
|
|
{
|
|
|
|
|
return &ropkg_error_vend;
|
|
|
|
|
}
|