/* error.c generated by valac 0.56.19, the Vala compiler
 * generated from error.vala, do not modify */

#include "crypto-vala.h"
#include <gcrypt.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

VALA_EXTERN void crypto_may_throw_gcrypt_error (gcry_error_t e,
                                    GError** error);

GQuark
crypto_error_quark (void)
{
	return g_quark_from_static_string ("crypto-error-quark");
}

static GType
crypto_error_get_type_once (void)
{
	static const GEnumValue values[] = {{CRYPTO_ERROR_ILLEGAL_ARGUMENTS, "CRYPTO_ERROR_ILLEGAL_ARGUMENTS", "illegal-arguments"}, {CRYPTO_ERROR_GCRYPT, "CRYPTO_ERROR_GCRYPT", "gcrypt"}, {CRYPTO_ERROR_AUTHENTICATION_FAILED, "CRYPTO_ERROR_AUTHENTICATION_FAILED", "authentication-failed"}, {CRYPTO_ERROR_UNKNOWN, "CRYPTO_ERROR_UNKNOWN", "unknown"}, {0, NULL, NULL}};
	GType crypto_error_type_id;
	crypto_error_type_id = g_enum_register_static ("CryptoError", values);
	return crypto_error_type_id;
}

GType
crypto_error_get_type (void)
{
	static volatile gsize crypto_error_type_id__once = 0;
	if (g_once_init_enter (&crypto_error_type_id__once)) {
		GType crypto_error_type_id;
		crypto_error_type_id = crypto_error_get_type_once ();
		g_once_init_leave (&crypto_error_type_id__once, crypto_error_type_id);
	}
	return crypto_error_type_id__once;
}

void
crypto_may_throw_gcrypt_error (gcry_error_t e,
                               GError** error)
{
	GError* _inner_error0_ = NULL;
	if (((gint) e) != 0) {
		const gchar* _tmp0_;
		GError* _tmp1_;
		_tmp0_ = gcry_strerror (e);
		_tmp1_ = g_error_new_literal (CRYPTO_ERROR, CRYPTO_ERROR_GCRYPT, _tmp0_);
		_inner_error0_ = _tmp1_;
		if (_inner_error0_->domain == CRYPTO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

