Moved all GError domains into one global GSWE_ERROR domain
This commit is contained in:
parent
16003cebe9
commit
b73ac78f17
@ -1,9 +1,6 @@
|
|||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gswe-moment</FILE>
|
<FILE>gswe-moment</FILE>
|
||||||
<TITLE>GsweMoment</TITLE>
|
<TITLE>GsweMoment</TITLE>
|
||||||
GSWE_MOMENT_ERROR
|
|
||||||
gswe_moment_error_quark
|
|
||||||
GsweMomentError
|
|
||||||
GsweMoment
|
GsweMoment
|
||||||
GsweMomentClass
|
GsweMomentClass
|
||||||
gswe_moment_new
|
gswe_moment_new
|
||||||
@ -180,9 +177,6 @@ gswe_house_data_get_type
|
|||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gswe-timestamp</FILE>
|
<FILE>gswe-timestamp</FILE>
|
||||||
<TITLE>GsweTimestamp</TITLE>
|
<TITLE>GsweTimestamp</TITLE>
|
||||||
GSWE_TIMESTAMP_ERROR
|
|
||||||
gswe_timestamp_error_quark
|
|
||||||
GsweTimestampError
|
|
||||||
GsweTimestamp
|
GsweTimestamp
|
||||||
GsweTimestampClass
|
GsweTimestampClass
|
||||||
gswe_timestamp_new
|
gswe_timestamp_new
|
||||||
@ -238,6 +232,9 @@ gswe_coordinates_get_type
|
|||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>swe-glib</FILE>
|
<FILE>swe-glib</FILE>
|
||||||
|
GsweError
|
||||||
|
gswe_error_quark
|
||||||
|
GSWE_ERROR
|
||||||
gswe_init
|
gswe_init
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
@ -385,15 +385,6 @@ gswe_moment_get_house_system(GsweMoment *moment)
|
|||||||
return moment->priv->house_system;
|
return moment->priv->house_system;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gswe_moment_error_quark:
|
|
||||||
*
|
|
||||||
* Gets the GsweMoment Error Quark.
|
|
||||||
*
|
|
||||||
* Return value: a #GQuark
|
|
||||||
*/
|
|
||||||
G_DEFINE_QUARK(gswe-moment-error-quark, gswe_moment_error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_moment_new:
|
* gswe_moment_new:
|
||||||
*
|
*
|
||||||
@ -511,7 +502,7 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((house_system_data = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) {
|
if ((house_system_data = g_hash_table_lookup(gswe_house_system_info_table, GINT_TO_POINTER(moment->priv->house_system))) == NULL) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_UNKNOWN_HSYS, "Unknown house system");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_HSYS, "Unknown house system");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -540,7 +531,7 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
|
|||||||
g_list_free_full(moment->priv->house_list, g_free);
|
g_list_free_full(moment->priv->house_list, g_free);
|
||||||
moment->priv->house_list = NULL;
|
moment->priv->house_list = NULL;
|
||||||
moment->priv->house_revision = 0;
|
moment->priv->house_revision = 0;
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_UNKNOWN_SIGN, "Calculation brought an unknown sign");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -690,11 +681,11 @@ gswe_moment_calculate_planet(GsweMoment *moment, GswePlanet planet, GError **err
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = swe_calc(jd, planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) {
|
if ((ret = swe_calc(jd, planet_data->planet_info->sweph_id, SEFLG_SPEED | SEFLG_TOPOCTR, x2, serr)) < 0) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_SWE_ERROR_FATAL, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) {
|
} else if (ret != (SEFLG_SPEED | SEFLG_TOPOCTR)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_NONFATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
}
|
}
|
||||||
|
|
||||||
gswe_calculate_data_by_position(moment, planet, x2[0], &calc_err);
|
gswe_calculate_data_by_position(moment, planet, x2[0], &calc_err);
|
||||||
@ -868,7 +859,7 @@ gswe_moment_get_planet(GsweMoment *moment, GswePlanet planet, GError **err)
|
|||||||
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
|
GswePlanetData *planet_data = (GswePlanetData *)(g_list_find_custom(moment->priv->planet_list, &planet, find_by_planet_id)->data);
|
||||||
|
|
||||||
if (planet_data == NULL) {
|
if (planet_data == NULL) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1157,7 +1148,7 @@ gswe_moment_get_planet_aspects(GsweMoment *moment, GswePlanet planet, GError **e
|
|||||||
*aspect;
|
*aspect;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1308,7 +1299,7 @@ gswe_moment_get_all_planet_antiscia(GsweMoment *moment, GswePlanet planet, GErro
|
|||||||
*antiscion;
|
*antiscion;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1379,7 +1370,7 @@ gswe_moment_get_axis_planet_antiscia(GsweMoment *moment, GsweAntiscionAxis axis,
|
|||||||
*antiscion_l;
|
*antiscion_l;
|
||||||
|
|
||||||
if (!gswe_moment_has_planet(moment, planet)) {
|
if (!gswe_moment_has_planet(moment, planet)) {
|
||||||
g_set_error(err, GSWE_MOMENT_ERROR, GSWE_MOMENT_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NONADDED_PLANET, "Specified planet is not added to the moment object");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -36,42 +36,6 @@ typedef struct _GsweMoment GsweMoment;
|
|||||||
typedef struct _GsweMomentClass GsweMomentClass;
|
typedef struct _GsweMomentClass GsweMomentClass;
|
||||||
typedef struct _GsweMomentPrivate GsweMomentPrivate;
|
typedef struct _GsweMomentPrivate GsweMomentPrivate;
|
||||||
|
|
||||||
/**
|
|
||||||
* GSWE_MOMENT_ERROR:
|
|
||||||
*
|
|
||||||
* Error domain for GsweMoment. Errors in this domain will be from
|
|
||||||
* #GsweMomentError enumeration. See #GError for more information on error
|
|
||||||
* domains.
|
|
||||||
*/
|
|
||||||
#define GSWE_MOMENT_ERROR gswe_moment_error_quark()
|
|
||||||
GQuark gswe_moment_error_quark(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweMomentError:
|
|
||||||
* @GSWE_MOMENT_ERROR_SUCCESS: no error
|
|
||||||
* @GSWE_MOMENT_ERROR_UNKNOWN_HSYS: house system provided is unknown (a
|
|
||||||
* #GsweHouseSystem value must be passed)
|
|
||||||
* @GSWE_MOMENT_ERROR_UNKNOWN_SIGN: an unknown zodiac sign is calculated
|
|
||||||
* @GSWE_MOMENT_ERROR_NONADDED_PLANET: the referenced planet is not added to
|
|
||||||
* the GsweMoment object
|
|
||||||
* @GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL: an error reported by the Swiss
|
|
||||||
* Ephemeris library. Errors marked with
|
|
||||||
* this value are not fatal, so it's
|
|
||||||
* more like a warning
|
|
||||||
* @GSWE_MOMENT_ERROR_SWE_ERROR_FATAL: a fatal error reported by the Swiss
|
|
||||||
* Ephemeris library
|
|
||||||
*
|
|
||||||
* Error codes returned by GsweMoment functions.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
GSWE_MOMENT_ERROR_SUCCESS,
|
|
||||||
GSWE_MOMENT_ERROR_UNKNOWN_HSYS,
|
|
||||||
GSWE_MOMENT_ERROR_UNKNOWN_SIGN,
|
|
||||||
GSWE_MOMENT_ERROR_NONADDED_PLANET,
|
|
||||||
GSWE_MOMENT_ERROR_SWE_ERROR_NONFATAL,
|
|
||||||
GSWE_MOMENT_ERROR_SWE_ERROR_FATAL
|
|
||||||
} GsweMomentError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweMoment:
|
* GsweMoment:
|
||||||
*
|
*
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "../swe/src/swephexp.h"
|
#include "../swe/src/swephexp.h"
|
||||||
#include "swe-glib-private.h"
|
#include "swe-glib-private.h"
|
||||||
|
#include "swe-glib.h"
|
||||||
#include "gswe-timestamp.h"
|
#include "gswe-timestamp.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -383,7 +384,7 @@ gswe_timestamp_calculate_gregorian(GsweTimestamp *timestamp, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timestamp->priv->valid_dates == 0) {
|
if (timestamp->priv->valid_dates == 0) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_NO_VALID, "This timestamp object holds no valid values");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,14 +803,14 @@ gswe_timestamp_calculate_julian(GsweTimestamp *timestamp, GError **err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (timestamp->priv->valid_dates == 0) {
|
if (timestamp->priv->valid_dates == 0) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_NO_VALID, "This timestamp object holds no valid values");
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_NO_VALID_VALUE, "This timestamp object holds no valid values");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
swe_utc_time_zone(timestamp->priv->gregorian_year, timestamp->priv->gregorian_month, timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second);
|
swe_utc_time_zone(timestamp->priv->gregorian_year, timestamp->priv->gregorian_month, timestamp->priv->gregorian_day, timestamp->priv->gregorian_hour, timestamp->priv->gregorian_minute, timestamp->priv->gregorian_second + timestamp->priv->gregorian_microsecond / 1000.0, timestamp->priv->gregorian_timezone_offset, &utc_year, &utc_month, &utc_day, &utc_hour, &utc_minute, &utc_second);
|
||||||
|
|
||||||
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) {
|
if ((retval = swe_utc_to_jd(utc_year, utc_month, utc_day, utc_hour, utc_minute, utc_second, SE_GREG_CAL, dret, serr)) == ERR) {
|
||||||
g_set_error(err, GSWE_TIMESTAMP_ERROR, GSWE_TIMESTAMP_ERROR_SWE_ERROR, "Swiss Ephemeris error: %s", serr);
|
g_set_error(err, GSWE_ERROR, GSWE_ERROR_SWE_FATAL, "Swiss Ephemeris error: %s", serr);
|
||||||
} else {
|
} else {
|
||||||
timestamp->priv->julian_day = dret[0];
|
timestamp->priv->julian_day = dret[0];
|
||||||
timestamp->priv->valid_dates |= VALID_JULIAN_DAY;
|
timestamp->priv->valid_dates |= VALID_JULIAN_DAY;
|
||||||
@ -853,15 +854,6 @@ gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err)
|
|||||||
return timestamp->priv->julian_day;
|
return timestamp->priv->julian_day;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gswe_timestamp_error_quark:
|
|
||||||
*
|
|
||||||
* Gets the GsweTimestamp Error Quark.
|
|
||||||
*
|
|
||||||
* Return value: a #GQuark
|
|
||||||
*/
|
|
||||||
G_DEFINE_QUARK(gswe-timestamp-error-quark, gswe_timestamp_error);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gswe_timestamp_new:
|
* gswe_timestamp_new:
|
||||||
*
|
*
|
||||||
|
@ -32,39 +32,6 @@ typedef struct _GsweTimestamp GsweTimestamp;
|
|||||||
typedef struct _GsweTimestampClass GsweTimestampClass;
|
typedef struct _GsweTimestampClass GsweTimestampClass;
|
||||||
typedef struct _GsweTimestampPrivate GsweTimestampPrivate;
|
typedef struct _GsweTimestampPrivate GsweTimestampPrivate;
|
||||||
|
|
||||||
/**
|
|
||||||
* GSWE_TIMESTAMP_ERROR:
|
|
||||||
*
|
|
||||||
* Error domain for GsweTimestamp. Errors in this domain will be from
|
|
||||||
* #GsweTimestampError enumeration. See #GError for more information on error
|
|
||||||
* domains.
|
|
||||||
*/
|
|
||||||
#define GSWE_TIMESTAMP_ERROR (gswe_timestamp_error_quark())
|
|
||||||
GQuark gswe_timestamp_error_quark(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GsweTimestampError:
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_SUCCESS: no error
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_INVALID_DATE: the Gregorian date specified in this
|
|
||||||
* GsweTimestamp is invalid
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_INVALID_TIME: the time specified in this
|
|
||||||
* GsweTimestamp is invalid
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_NO_VALID: the GsweTimestamp object holds no valid
|
|
||||||
* timestamp
|
|
||||||
* @GSWE_TIMESTAMP_ERROR_SWE_ERROR: denotes an error detected by the Swiss
|
|
||||||
* Ephemeris library, converted from their
|
|
||||||
* static char array to a #GError
|
|
||||||
*
|
|
||||||
* Error codes returned by GsweTimestamp functions.
|
|
||||||
*/
|
|
||||||
typedef enum {
|
|
||||||
GSWE_TIMESTAMP_ERROR_SUCCESS,
|
|
||||||
GSWE_TIMESTAMP_ERROR_INVALID_DATE,
|
|
||||||
GSWE_TIMESTAMP_ERROR_INVALID_TIME,
|
|
||||||
GSWE_TIMESTAMP_ERROR_NO_VALID,
|
|
||||||
GSWE_TIMESTAMP_ERROR_SWE_ERROR
|
|
||||||
} GsweTimestampError;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GsweTimestamp:
|
* GsweTimestamp:
|
||||||
*
|
*
|
||||||
|
@ -87,6 +87,15 @@ GsweTimestamp *gswe_full_moon_base_date;
|
|||||||
(v)->sign_offset = m; \
|
(v)->sign_offset = m; \
|
||||||
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gswe_error_quark:
|
||||||
|
*
|
||||||
|
* Gets the SWE-GLib Error Quark.
|
||||||
|
*
|
||||||
|
* Return value: a #GQuark
|
||||||
|
*/
|
||||||
|
G_DEFINE_QUARK(gswe-error-quark, gswe_error);
|
||||||
|
|
||||||
void
|
void
|
||||||
gswe_free_planet_info(gpointer planet_info)
|
gswe_free_planet_info(gpointer planet_info)
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,43 @@
|
|||||||
#include "gswe-moment.h"
|
#include "gswe-moment.h"
|
||||||
#include "gswe-enumtypes.h"
|
#include "gswe-enumtypes.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GsweError:
|
||||||
|
* @GSWE_ERROR_SUCCESS: No error
|
||||||
|
* @GSWE_ERROR_SWE_NONFATAL: Non-fatal Swiss Ephemeris library error
|
||||||
|
* @GSWE_ERROR_SWE_FATAL: Fatal Swiss Ephemeris library error
|
||||||
|
* @GSWE_ERROR_INVALID_DATE: The specified Gregorian date is invalid
|
||||||
|
* @GSWE_ERROR_INVALID_TIME: The specified time is invalid
|
||||||
|
* @GSWE_ERROR_NO_VALID_VALUE: the #GsweTimestamp object holds no valid values
|
||||||
|
* @GSWE_ERROR_UNKNOWN_HSYS: the requested house system is unknown
|
||||||
|
* @GSWE_ERROR_UNKNOWN_SIGN: an invalid zodiac sign would have been returned
|
||||||
|
* @GSWE_ERROR_NONADDED_PLANET: the referenced planet was not added with
|
||||||
|
* gswe_moment_add_planet()
|
||||||
|
*
|
||||||
|
* Error codes returned by the SWE-GLib functions.
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
GSWE_ERROR_SUCCESS,
|
||||||
|
GSWE_ERROR_SWE_NONFATAL,
|
||||||
|
GSWE_ERROR_SWE_FATAL,
|
||||||
|
GSWE_ERROR_INVALID_DATE,
|
||||||
|
GSWE_ERROR_INVALID_TIME,
|
||||||
|
GSWE_ERROR_NO_VALID_VALUE,
|
||||||
|
GSWE_ERROR_UNKNOWN_HSYS,
|
||||||
|
GSWE_ERROR_UNKNOWN_SIGN,
|
||||||
|
GSWE_ERROR_NONADDED_PLANET,
|
||||||
|
} GsweError;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GSWE_ERROR:
|
||||||
|
*
|
||||||
|
* Error domain for SWE-GLib in general. Since 2.0, all errors generated by
|
||||||
|
* SWE-GLib functions are from this domain. See #GError for more information on
|
||||||
|
* error domains.
|
||||||
|
*/
|
||||||
|
#define GSWE_ERROR gswe_error_quark()
|
||||||
|
GQuark gswe_error_quark(void);
|
||||||
|
|
||||||
void gswe_init();
|
void gswe_init();
|
||||||
|
|
||||||
#endif /* __SWE_GLIB_H__ */
|
#endif /* __SWE_GLIB_H__ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user