aboutsummaryrefslogtreecommitdiff
path: root/kernel/kapi/system.cpp
blob: 23dadd3a8ecc7462baa3f0319cbd40c393d1abd3 (plain)
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
#include <kapi/system.hpp>

#include <kapi/cpu.hpp>

#include <kstd/print.hpp>
#include <kstd/system_error.hpp>

#include <source_location>
#include <string_view>

namespace kapi::system
{

  [[gnu::weak]]
  auto panic(std::string_view message, std::source_location location) -> void
  {
    kstd::println(kstd::print_sink::stderr, "[PANIC] in {} : {} @ {}:{}", location.function_name(), message,
                  location.file_name(), location.line());
    cpu::halt();
  }

  [[gnu::weak]]
  auto panic(std::string_view message, kstd::error_code error, std::source_location location) -> void
  {
    kstd::println(kstd::print_sink::stderr, "[PANIC] in {} : {} ({}:{}) @ {}:{}", location.function_name(), message,
                  error.category().name(), error.message(), location.file_name(), location.line());
    cpu::halt();
  }

}  // namespace kapi::system