Attempt at implementing per-channel output setting in the sampler.
[calfbox.git] / errors.c
blob0fec3e0e0d83ac8738e5fe1cadda919670c9b875
1 /*
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/>.
19 #include "errors.h"
21 GQuark cbox_module_error_quark()
23 return g_quark_from_string("cbox-module-error-quark");
26 void cbox_force_error(GError **error)
28 if (error && !*error)
29 g_set_error(error, CBOX_MODULE_ERROR, CBOX_MODULE_ERROR_FAILED, "unknown error");
32 void cbox_print_error(GError *error)
34 if (!error)
36 g_warning("Unspecified error");
37 return;
39 g_warning("%s", error->message);
40 g_error_free(error);
43 void cbox_print_error_if(GError *error)
45 if (!error)
46 return;
47 g_warning("%s", error->message);
48 g_error_free(error);
51 gboolean cbox_set_command_error(GError **error, const struct cbox_osc_command *cmd)
53 if (error && !*error)
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);
55 return FALSE;
58 gboolean cbox_set_command_error_with_msg(GError **error, const struct cbox_osc_command *cmd, const char *extra_msg)
60 if (error && !*error)
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);
62 return FALSE;
65 gboolean cbox_set_range_error(GError **error, const char *param, double minv, double maxv)
67 if (error && !*error)
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);
69 return FALSE;