forked from scylladb/scylladb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathon_internal_error.hh
34 lines (27 loc) · 1.13 KB
/
on_internal_error.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
* Copyright (C) 2024-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
// Seastar's on_internal_error() is a replacement for SCYLLA_ASSERT(). Instead of
// crashing like SCYLLA_ASSERT(), on_internal_error() logs a message with a
// backtrace and throws an exception (and optionally also crashes - this can
// be useful for testing). However, Seastar's function is inconvenient because
// it requires specifying a logger. This makes it hard to call it from source
// files which don't already have a logger, or in code in a header file.
//
// So here we provide Scylla's version of on_internal_error() which uses a
// single logger for all internal errors - with no need to specify a logger
// object to each call.
#pragma once
#include <string_view>
namespace utils {
/// Report an internal error
///
/// Depending on the value passed to seastar::set_abort_on_internal_error(),
/// this will either abort or throw a std::runtime_error.
/// In both cases an error will be logged, containing \p reason and the
/// current backtrace.
[[noreturn]] void on_internal_error(std::string_view reason);
}