2** EPITECH PROJECT, 2025
5** Error.tpp, Error class template implementation
11** Copyright (c) 2025 Robin Toillon
13** Permission is hereby granted, free of charge, to any person obtaining
14** a copy of this software and associated documentation files (the
15** "Software"), to deal in the Software without restriction, including
16** without limitation the rights to use, copy, modify, merge, publish,
17** distribute, sublicense, and/or sell copies of the Software, and to
18** permit persons to whom the Software is furnished to do so, subject to
19** the following conditions:
21** The above copyright notice and this permission notice shall be
22** included in all copies or substantial portions of the Software.
24** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35 * @brief Error class template implementations
36 * @author Robin Toillon
37 * @details Implements the factory methods for creating Error objects
38 * with different severity levels (failure, warning, fatal) and
46 template <typename ...Args>
47 auto Error::failure(ErrorCode code,
48 std::format_string<Args...> fmt,
49 Args &&...args) -> Error
51 return Error(code, log::Level::Error,
52 std::format(fmt, std::forward<Args>(args)...));
55 template <typename ...Args>
56 auto Error::warning(ErrorCode code,
57 std::format_string<Args...> fmt,
58 Args &&...args) -> Error
60 return Error(code, log::Level::Warning,
61 std::format(fmt, std::forward<Args>(args)...));
64 template <typename ...Args>
65 auto Error::fatal(ErrorCode code,
66 std::format_string<Args...> fmt,
67 Args &&...args) -> Error
69 return Error(code, log::Level::Fatal,
70 std::format(fmt, std::forward<Args>(args)...));