durs_common_tools/macros/
fatal_error.rs

1//  Copyright (C) 2019  Éloïs SANCHEZ
2//
3// This program is free software: you can redistribute it and/or modify
4// it under the terms of the GNU Affero General Public License as
5// published by the Free Software Foundation, either version 3 of the
6// License, or (at your option) any later version.
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11// GNU Affero General Public License for more details.
12//
13// You should have received a copy of the GNU Affero General Public License
14// along with this program.  If not, see <https://www.gnu.org/licenses/>.
15
16//! Fatal error macro for DURS project.
17
18/// Interrupts the program and log error message
19/// WARNING: this macro must not be called before the logger is initialized !
20#[macro_export]
21macro_rules! fatal_error {
22    ($msg:expr) => ({
23        error!("{}", &dbg!($msg));
24        panic!($msg);
25    });
26    ($msg:expr,) => ({
27        error!("{}", &dbg!($msg));
28        panic!($msg);
29    });
30    ($fmt:expr, $($arg:tt)+) => ({
31        error!("{}", dbg!(format!($fmt, $($arg)+)));
32        panic!($fmt, $($arg)+);
33    });
34}