libvisual
0.5.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
libvisual
lv_error.c
1
/* Libvisual - The audio visualisation framework.
2
*
3
* Copyright (C) 2012-2013 Libvisual team
4
* 2004-2006 Dennis Smit
5
*
6
* Authors: Dennis Smit <ds@nerds-incorporated.org>
7
* Chong Kai Xiong <kaixiong@codeleft.sg>
8
*
9
* This program is free software; you can redistribute it and/or modify
10
* it under the terms of the GNU Lesser General Public License as
11
* published by the Free Software Foundation; either version 2.1
12
* of the License, or (at your option) any later version.
13
*
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU Lesser General Public License for more details.
18
*
19
* You should have received a copy of the GNU Lesser General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
*/
23
24
#include "config.h"
25
#include "lv_error.h"
26
#include "lv_log.h"
27
#include "lv_checks.h"
28
#include "gettext.h"
29
#include <stdlib.h>
30
#include <signal.h>
31
32
static
void
log_and_exit (
const
char
*error);
33
34
static
VisErrorHandlerFunc
error_handler = NULL;
35
static
void
*error_handler_priv = NULL;
36
37
void
visual_error_raise
(
const
char
*error)
38
{
39
if
(error_handler) {
40
error_handler (error, error_handler_priv);
41
}
else
{
42
log_and_exit (error);
43
}
44
}
45
46
void
visual_error_set_handler
(
VisErrorHandlerFunc
handler,
void
*priv)
47
{
48
error_handler = handler;
49
error_handler_priv = priv;
50
}
51
52
static
void
log_and_exit (
const
char
*error)
53
{
54
visual_log
(
VISUAL_LOG_CRITICAL
,
"Aborting due to error: %s"
, error);
55
56
#ifdef VISUAL_OS_POSIX
57
raise
(SIGTRAP);
58
#endif
59
60
exit (EXIT_FAILURE);
61
}