Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi committed Aug 30, 2023
1 parent 874abb6 commit 6191ef9
Show file tree
Hide file tree
Showing 60 changed files with 1,658 additions and 1,111 deletions.
Binary file added meos/examples/test_setagg
Binary file not shown.
154 changes: 77 additions & 77 deletions meos/include/general/error.h
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
/*****************************************************************************
*
* This MobilityDB code is provided under The PostgreSQL License.
* Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
* contributors
*
* MobilityDB includes portions of PostGIS version 3 source code released
* under the GNU General Public License (GPLv2 or later).
* Copyright (c) 2001-2023, PostGIS contributors
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without a written
* agreement is hereby granted, provided that the above copyright notice and
* this paragraph and the following two paragraphs appear in all copies.
*
* IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
* EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
* AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*****************************************************************************/

/**
* @file
* @brief Error handling.
*/

/* C */
#include <errno.h>
/* MEOS */
#include <meos.h>

typedef enum
{
MEOS_SUCCESS = 0, // Successful operation

MEOS_ERR_INTERNAL_ERROR = 1, // Unspecified internal error
MEOS_ERR_INTERNAL_TYPE_ERROR = 2, // Internal type error
MEOS_ERR_VALUE_OUT_OF_RANGE = 3, // Internal out of range error
MEOS_ERR_DIVISION_BY_ZERO = 4, // Internal division by zero error
MEOS_ERR_MEMORY_ALLOC_ERROR = 5, // Internal malloc error
MEOS_ERR_AGGREGATION_ERROR = 6, // Internal aggregation error
MEOS_ERR_DIRECTORY_ERROR = 7, // Internal directory error
MEOS_ERR_FILE_ERROR = 8, // Internal file error

MEOS_ERR_INVALID_ARG = 10, // Invalid argument
MEOS_ERR_INVALID_ARG_TYPE = 11, // Invalid argument type
MEOS_ERR_INVALID_ARG_VALUE = 12, // Invalid argument value

MEOS_ERR_MFJSON_INPUT = 20, // MFJSON input error
MEOS_ERR_MFJSON_OUTPUT = 21, // MFJSON output error
MEOS_ERR_TEXT_INPUT = 22, // Text input error
MEOS_ERR_TEXT_OUTPUT = 23, // Text output error
MEOS_ERR_WKB_INPUT = 24, // WKB input error
MEOS_ERR_WKB_OUTPUT = 25, // WKB output error
MEOS_ERR_GEOJSON_INPUT = 26, // GEOJSON input error
MEOS_ERR_GEOJSON_OUTPUT = 27, // GEOJSON output error

} errorCode;

extern void meos_error(int errlevel, int errcode, char *format, ...);

/* Set or read error level */

extern int mobdb_errno(void);
extern int mobdb_errno_set(int err);
extern int mobdb_errno_restore(int err);
extern int mobdb_errno_reset(void);

/*****************************************************************************/
/*****************************************************************************
*
* This MobilityDB code is provided under The PostgreSQL License.
* Copyright (c) 2016-2023, Université libre de Bruxelles and MobilityDB
* contributors
*
* MobilityDB includes portions of PostGIS version 3 source code released
* under the GNU General Public License (GPLv2 or later).
* Copyright (c) 2001-2023, PostGIS contributors
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without a written
* agreement is hereby granted, provided that the above copyright notice and
* this paragraph and the following two paragraphs appear in all copies.
*
* IN NO EVENT SHALL UNIVERSITE LIBRE DE BRUXELLES BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
* EVEN IF UNIVERSITE LIBRE DE BRUXELLES HAS BEEN ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* UNIVERSITE LIBRE DE BRUXELLES SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON
* AN "AS IS" BASIS, AND UNIVERSITE LIBRE DE BRUXELLES HAS NO OBLIGATIONS TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
*****************************************************************************/

/**
* @file
* @brief Error handling.
*/

/* C */
#include <errno.h>
/* MEOS */
#include <meos.h>

typedef enum
{
MEOS_SUCCESS = 0, // Successful operation

MEOS_ERR_INTERNAL_ERROR = 1, // Unspecified internal error
MEOS_ERR_INTERNAL_TYPE_ERROR = 2, // Internal type error
MEOS_ERR_VALUE_OUT_OF_RANGE = 3, // Internal out of range error
MEOS_ERR_DIVISION_BY_ZERO = 4, // Internal division by zero error
MEOS_ERR_MEMORY_ALLOC_ERROR = 5, // Internal malloc error
MEOS_ERR_AGGREGATION_ERROR = 6, // Internal aggregation error
MEOS_ERR_DIRECTORY_ERROR = 7, // Internal directory error
MEOS_ERR_FILE_ERROR = 8, // Internal file error

MEOS_ERR_INVALID_ARG = 10, // Invalid argument
MEOS_ERR_INVALID_ARG_TYPE = 11, // Invalid argument type
MEOS_ERR_INVALID_ARG_VALUE = 12, // Invalid argument value

MEOS_ERR_MFJSON_INPUT = 20, // MFJSON input error
MEOS_ERR_MFJSON_OUTPUT = 21, // MFJSON output error
MEOS_ERR_TEXT_INPUT = 22, // Text input error
MEOS_ERR_TEXT_OUTPUT = 23, // Text output error
MEOS_ERR_WKB_INPUT = 24, // WKB input error
MEOS_ERR_WKB_OUTPUT = 25, // WKB output error
MEOS_ERR_GEOJSON_INPUT = 26, // GEOJSON input error
MEOS_ERR_GEOJSON_OUTPUT = 27, // GEOJSON output error

} errorCode;

extern void meos_error(int errlevel, int errcode, char *format, ...);

/* Set or read error level */

extern int mobdb_errno(void);
extern int mobdb_errno_set(int err);
extern int mobdb_errno_restore(int err);
extern int mobdb_errno_reset(void);

/*****************************************************************************/
8 changes: 6 additions & 2 deletions meos/include/general/temporal.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,21 @@ extern bool ensure_not_null(void *ptr);
extern bool ensure_one_not_null(void *ptr1, void *ptr2);
extern bool ensure_valid_interpolation(meosType temptype, interpType interp);
extern bool ensure_continuous(const Temporal *temp);
extern bool ensure_continuous_interpolation(int16 flags);
extern bool ensure_discrete_interpolation(int16 flags);
extern bool ensure_same_interpolation(const Temporal *temp1, const Temporal *temp2);
extern bool ensure_same_continuous_interpolation(int16 flags1, int16 flags2);
extern bool ensure_nonlinear_interpolation(int16 flags);
extern bool ensure_common_dimension(int16 flags1, int16 flags2);
extern bool ensure_temporal_has_type(const Temporal *temp, meosType temptype);
extern bool ensure_same_temporal_type(const Temporal *temp1,
const Temporal *temp2);
extern bool ensure_same_temporal_basetype(const Temporal *temp,
meosType basetype);
extern bool ensure_valid_tnumber_span(const Temporal *temp, const Span *s);
extern bool ensure_valid_tnumber_spanset(const Temporal *temp, const SpanSet *ss);
extern bool ensure_valid_tnumber_tbox(const Temporal *temp, const TBox *box);
extern bool ensure_non_negative(int i);
extern bool ensure_positive(int i);
extern bool ensure_less_equal(int i, int j);
extern bool positive_datum(Datum size, meosType basetype);
extern bool ensure_positive_datum(Datum size, meosType basetype);
extern bool valid_duration(const Interval *duration);
Expand Down
Loading

0 comments on commit 6191ef9

Please sign in to comment.