Skip to content

Commit

Permalink
Improve error management
Browse files Browse the repository at this point in the history
  • Loading branch information
estebanzimanyi committed Oct 4, 2023
1 parent e1e42c2 commit 7691cdd
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 76 deletions.
58 changes: 29 additions & 29 deletions meos/include/general/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,42 +35,42 @@
#ifndef __ERROR_H__
#define __ERROR_H__

typedef enum
{
MEOS_SUCCESS = 0, // Successful operation
// 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_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_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
// 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;
// } errorCode;

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

/* Set or read error level */
// /* 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);
// 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);

/*****************************************************************************/

Expand Down
2 changes: 1 addition & 1 deletion meos/include/general/temporal.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
/* PostgreSQL */
#include <postgres.h>
/* MEOS */
#include "general/error.h"
#include <meos.h>
#include "general/meos_catalog.h"
#include "general/span.h"
#include "general/set.h"
Expand Down
74 changes: 36 additions & 38 deletions meos/include/meos.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
#include "postgres_int_defs.h"
/* PostGIS */
#include <liblwgeom.h>
/* MEOS */
#include "general/error.h" /* For error codes */

/*****************************************************************************
* Toolchain dependent definitions
Expand Down Expand Up @@ -283,42 +281,42 @@ typedef struct
* Error codes
*****************************************************************************/

// 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);
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);

/*****************************************************************************
* Initialization of the MEOS library
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/common/pgfnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "postgres.h"

#include "../../include/meos.h"

/*
* pgfnames
*
Expand Down
1 change: 0 additions & 1 deletion meos/postgres/postgres.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#define POSTGRES_H

#include "c.h"
#include "../include/general/error.h" /* For error codes */

/*
* MEOS: redefining elog
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/timezone/pgtz.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "utils/timestamp_def.h"
#include "pgtz.h"

#include "../../include/meos.h"

/**
* Structure to represent the timezone cache hash table, which extends
* the `ENTRY` structure used by hsearch
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/utils/datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "utils/datetime.h"
#include "utils/date.h"

#include "../../include/meos.h"

static const datetkn *datebsearch(const char *key, const datetkn *base, int nel);

/* Defined below */
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/utils/float.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <math.h>
#include <limits.h>

#include "../../include/meos.h"

/*
* Configurable GUC parameter
*
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/utils/formatting.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
#include "utils/date.h"
#include "utils/float.h"

#include "../../include/meos.h"

#define DEFAULT_COLLATION_OID 100

/*
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/utils/numutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "common/int.h"
#include "port/pg_bitutils.h"

#include "../../include/meos.h"

/*
* A table of all two-digit numbers. This is used to speed up decimal digit
* generation by copying pairs of digits into the final output.
Expand Down
2 changes: 2 additions & 0 deletions meos/postgres/utils/timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "postgres.h"

#include "../../include/meos.h"

// MEOS
// #include "datatype/timestamp.h"
#include "utils/timestamp_def.h"
Expand Down
14 changes: 7 additions & 7 deletions meos/src/general/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@
* https://github.com/OSGeo/PROJ/blob/master/src/4D_api.cpp
*/

#include "general/error.h"

/* C */
#include <errno.h>
#include <stdarg.h>
/* Postgres */
#include <postgres.h>
#if ! MEOS
#include <utils/elog.h>
#else
#include <meos.h>
#endif /* ! MEOS */
/* MEOS */
// #if ! MEOS
// #include <utils/elog.h>
// #else
// #include <meos.h>
// #endif /* ! MEOS */
#include <meos.h>

/*****************************************************************************/

Expand Down

0 comments on commit 7691cdd

Please sign in to comment.