Program Listing for File error.h
↰ Return to documentation for file (caprock/error.h
)
/*
* This file is part of caprock.
*
* Author(s): Jens Finkhaeuser <jens@finkhaeuser.de>
*
* Copyright (c) 2022 Interpeer gUG (haftungsbeschränkt).
*
* SPDX-License-Identifier: GPL-3.0-only
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
#ifndef CAPROCK_ERROR_H
#define CAPROCK_ERROR_H
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include <caprock.h>
#if !defined(CAPROCK_START_ERRORS)
#define CAPROCK_START_ERRORS \
typedef uint32_t caprock_error_t; \
enum caprock_error_code {
#define CAPROCK_ERRDEF(name, code, desc) CAPROCK_ ## name = code,
#define CAPROCK_END_ERRORS \
CAPROCK_ERROR_LAST, \
CAPROCK_START_USER_RANGE = 1000 };
#define CAPROCK_ERROR_FUNCTIONS
#endif
/*****************************************************************************
* Error definitions
**/
CAPROCK_START_ERRORS
CAPROCK_ERRDEF(ERR_SUCCESS,
0,
"No error")
CAPROCK_ERRDEF(ERR_UNEXPECTED,
1,
"Nobody expects the Spanish Inquisition!")
CAPROCK_ERRDEF(ERR_INVALID_VALUE,
2,
"An invalid parameter value was provided.")
CAPROCK_ERRDEF(ERR_INVALID_KEY,
10,
"Invalid key data was passed to a function.")
CAPROCK_ERRDEF(ERR_VALIDATION,
11,
"Could not validate token with the given key.")
CAPROCK_ERRDEF(ERR_CODEC,
20,
"Error en- or decoding value.")
CAPROCK_ERRDEF(ERR_OUT_OF_MEMORY,
21,
"Out of memory or buffer size.")
CAPROCK_ERRDEF(ERR_ITERATION_END,
30,
"End of iteration.")
// TODO add errors as required
CAPROCK_END_ERRORS
#if defined(CAPROCK_ERROR_FUNCTIONS)
/*****************************************************************************
* Functions
**/
CAPROCK_API char const * caprock_error_message(caprock_error_t code);
CAPROCK_API char const * caprock_error_name(caprock_error_t code);
#endif // CAPROCK_ERROR_FUNCTIONS
#undef CAPROCK_START_ERRORS
#undef CAPROCK_ERRDEF
#undef CAPROCK_END_ERRORS
#undef CAPROCK_ERROR_FUNCTIONS
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // guard