system_error.hpp

 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
35
36
37
38
39
40
41
#pragma once


#include <felspar/exceptions/source_annotation.hpp>
#include <functional>
#include <system_error>


namespace felspar::stdexcept {


    class system_error :
    public exceptions::source_annotation<std::system_error> {
      public:
        system_error(
                std::error_code ec,
                source_location loc = source_location::current())
        : source_annotation<std::system_error>{loc, ec, annotate(loc)} {}
        system_error(
                std::error_code ec,
                std::string m,
                source_location loc = source_location::current())
        : source_annotation<std::system_error>{
                loc, ec, annotate(std::move(m), loc)} {}
        system_error(
                int const ev,
                std::error_category const &ecat,
                source_location loc = source_location::current())
        : source_annotation<std::system_error>{
                loc, ev, std::cref(ecat), annotate(loc)} {}
        system_error(
                int const ev,
                std::error_category const &ecat,
                std::string m,
                source_location loc = source_location::current())
        : source_annotation<std::system_error>{
                loc, ev, std::cref(ecat), annotate(std::move(m), loc)} {}
    };


}