2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2011 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 GQuark
cbox_module_error_quark()
23 return g_quark_from_string("cbox-module-error-quark");
26 void cbox_force_error(GError
**error
)
29 g_set_error(error
, CBOX_MODULE_ERROR
, CBOX_MODULE_ERROR_FAILED
, "unknown error");
32 void cbox_print_error(GError
*error
)
36 g_warning("Unspecified error");
39 g_warning("%s", error
->message
);
43 void cbox_print_error_if(GError
*error
)
47 g_warning("%s", error
->message
);
51 gboolean
cbox_set_command_error(GError
**error
, const struct cbox_osc_command
*cmd
)
54 g_set_error(error
, CBOX_MODULE_ERROR
, CBOX_MODULE_ERROR_OUT_OF_RANGE
, "Invalid command '%s' with args '%s'", cmd
->command
, cmd
->arg_types
);
58 gboolean
cbox_set_command_error_with_msg(GError
**error
, const struct cbox_osc_command
*cmd
, const char *extra_msg
)
61 g_set_error(error
, CBOX_MODULE_ERROR
, CBOX_MODULE_ERROR_OUT_OF_RANGE
, "Invalid command '%s' with args '%s': %s", cmd
->command
, cmd
->arg_types
, extra_msg
);
65 gboolean
cbox_set_range_error(GError
**error
, const char *param
, double minv
, double maxv
)
68 g_set_error(error
, CBOX_MODULE_ERROR
, CBOX_MODULE_ERROR_OUT_OF_RANGE
, "Parameter %s not within a valid range of [%f, %f]", param
, minv
, maxv
);