/* Generated file (by generator) */

/*
 * SPDX-FileCopyrightText: 2015 William Yu <williamyu@gnome.org>
 *
 * SPDX-License-Identifier: LGPL-2.1-only OR MPL-2.0
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "i-cal-error.h"
#include "libical-glib-private.h"

/**
 * i_cal_error_icalerrno:
 *
 * Returns the error stored in the library. If no error, return I_CAL_NO_ERROR.
 *
 * Returns: (transfer full): Return the error happened
 *
 * Since: 1.0
 *
 **/
ICalErrorEnum
i_cal_error_icalerrno (void)
{
	return (ICalErrorEnum) * (icalerror_icalerrno ());
}

/**
 * i_cal_error_clear_errno:
 *
 * Since: 1.0
 *
 **/
void
i_cal_error_clear_errno (void)
{
	icalerror_clear_errno ();
}

/**
 * i_cal_error_strerror:
 * @e: The #ICalErrorEnum to be translated
 *
 * Translates the #ICalErrorEnum to the string representation.
 *
 * Returns: (transfer none): The string representation of @e
 *
 * Since: 1.0
 *
 **/
const gchar *
i_cal_error_strerror (ICalErrorEnum e)
{
	return icalerror_strerror ((icalerrorenum) (e));
}

/**
 * i_cal_error_perror:
 *
 * Gets the #ICalErrorEnum in the string representation. This method called the icalerrorno_return to get
 * the current error.
 *
 * Returns: (transfer none): The string representation of the current error
 *
 * Since: 1.0
 *
 **/
const gchar *
i_cal_error_perror (void)
{
	return icalerror_perror ();
}

/**
 * i_calerror_backtrace:
 *
 * Since: 1.0
 *
 **/
void
i_calerror_backtrace (void)
{
	icalerror_backtrace ();
}

/**
 * i_cal_error_set_error_state:
 * @error: The error enum
 * @state: The error state
 *
 * Sets the state to the corresponding error in the library.
 *
 * Since: 1.0
 *
 **/
void
i_cal_error_set_error_state (ICalErrorEnum error, 
                             ICalErrorState state)
{
	icalerror_set_error_state ((icalerrorenum) (error), (icalerrorstate) (state));
}

/**
 * i_cal_error_get_error_state:
 * @error: The error to be checked
 *
 * Gets the state of an error.
 *
 * Returns: The state of the @error
 *
 * Since: 1.0
 *
 **/
ICalErrorState
i_cal_error_get_error_state (ICalErrorEnum error)
{
	return (ICalErrorState) (icalerror_get_error_state ((icalerrorenum) (error)));
}

/**
 * i_cal_error_set_errno:
 * @x: The error to be set
 *
 * Sets the errno.
 *
 * Since: 1.0
 *
 **/
void
i_cal_error_set_errno (ICalErrorEnum x)
{
	icalerror_set_errno ((icalerrorenum) (x));
}

/**
 * i_cal_error_supress:
 * @error: The error to be suppressed
 *
 * Suppresses the error.
 *
 * Returns: The error state suppressed
 *
 * Since: 1.0
 *
 **/
ICalErrorState
i_cal_error_supress (const gchar *error)
{
    g_return_val_if_fail (error != NULL, I_CAL_ERROR_UNKNOWN);

	return (ICalErrorState) (icalerror_supress (error));
}

/**
 * i_cal_error_restore:
 * @error: The error to be restored
 * @es: The error state to be restored
 *
 * Restores the error to specified state.
 *
 * Since: 1.0
 *
 **/
void
i_cal_error_restore (const gchar *error, 
                     ICalErrorState es)
{
    g_return_if_fail (error != NULL);

	icalerror_restore (error, (icalerrorstate) (es));
}

/**
 * i_cal_error_error_from_string:
 * @str: The error name string
 *
 * Reads an error from a string.
 *
 * Returns: An #ICalErrorEnum representation of the error @str
 *
 * Since: 4.0
 *
 **/
ICalErrorEnum
i_cal_error_error_from_string (const gchar *str)
{
    g_return_val_if_fail (str != NULL, I_CAL_UNKNOWN_ERROR);

	return (ICalErrorEnum) (icalerror_error_from_string (str));
}

/**
 * i_cal_error_get_errors_are_fatal:
 *
 * Determine whether errors are fatal.
 *
 * Returns: whether errors are fatal
 *
 * Since: 4.0
 *
 **/
gboolean
i_cal_error_get_errors_are_fatal (void)
{
	return icalerror_get_errors_are_fatal ();
}

/**
 * i_cal_error_set_errors_are_fatal:
 * @value: value to set
 *
 * Sets whether errors are fatal, that is, whether libical aborts after any processing reports an error.
 *
 * Since: 4.0
 *
 **/
void
i_cal_error_set_errors_are_fatal (gboolean value)
{
	icalerror_set_errors_are_fatal (value);
}
