summaryrefslogtreecommitdiff
path: root/graphics/asymptote/LspCpp/network/uri/uri_errors.hpp
blob: a192533dfd8db9c3f24912831542975f41755438 (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright 2013-2016 Glyn Matthews.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef NETWORK_URI_ERRORS_INC
#define NETWORK_URI_ERRORS_INC

/**
 * \file
 * \brief Contains functions and exceptions for URI error handling.
 */

#include <system_error>
#include <network/uri/config.hpp>

#ifdef NETWORK_URI_MSVC
#  pragma warning(push)
#  pragma warning(disable : 4251 4231 4660)
   // Disable C4275 too because it's "essentially noise and can be silenced"
   // according to Stephen T. Lavavej at Microsoft. See:
   // https://connect.microsoft.com/VisualStudio/feedback/details/696593/vc-10-vs-2010-basic-string-exports.
#  pragma warning(disable : 4275)
#endif

namespace network {

#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
  enum class uri_error {

    // parser errors
    invalid_syntax = 1,

    // builder errors
    invalid_uri,
    invalid_scheme,
    invalid_user_info,
    invalid_host,
    invalid_port,
    invalid_path,
    invalid_query,
    invalid_fragment,

    // encoding errors
    not_enough_input,
    non_hex_input,
    conversion_failed,
  };

  const std::error_category &uri_category();

  std::error_code make_error_code(uri_error e);
#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS)

  /**
   * \class uri_syntax_error uri.hpp network/uri.hpp
   * \brief An exception thrown by the \c uri constructor when a URI
   *        cannot be parsed.
   */
  class uri_syntax_error : public std::system_error {

  public:

    /**
     * \brief Constructor.
     */
    uri_syntax_error();

    /**
     * \brief Destructor.
     */
    virtual ~uri_syntax_error() noexcept;

  };

  /**
   * \class uri_builder_error uri.hpp network/uri.hpp
   * \brief An exception thrown when the \c uri_builder cannot build a
   *        valid URI.
   */
  class uri_builder_error : public std::system_error {

  public:

    /**
     * \brief Constructor.
     */
    uri_builder_error();

    /**
     * \brief Destructor.
     */
    virtual ~uri_builder_error() noexcept;

  };

  /**
   * \class percent_decoding_error uri.hpp network/uri.hpp
   * \brief An exception thrown when during percent decoding.
   */
  class percent_decoding_error : public std::system_error {

  public:

    /**
     * \brief Constructor.
     */
    explicit percent_decoding_error(uri_error error);

    /**
     * \brief Destructor.
     */
    virtual ~percent_decoding_error() noexcept;

  };
} // namespace network

#ifdef NETWORK_URI_MSVC
#pragma warning(pop)
#endif

#endif // NETWORK_URI_ERRORS_INC