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
|
### jsoncons::conv_error
```cpp
#include <jsoncons/conv_error.hpp>
```
<br>
`jsoncons::conv_error` defines an exception type for reporting type conversion failures.

std::exception
#### Constructors
conv_error(std::error_code ec);
conv_error(std::error_code ec, const std::string& what_arg);
conv_error(std::error_code ec, const char* what_arg);
conv_error(const conv_error& other);
conv_error(conv_error&& other);
#### Member functions
const char* what() const noexcept final
Returns an error message
#### Inherited from std::system_error
const std::error_code code() const noexcept
Returns an error code for this exception
### Example
```cpp
#include <jsoncons/json.hpp>
#include <iostream>
int main()
{
try
{
jsoncons::json j(10);
auto sv = j.as<std::string_view>();
}
catch (const jsoncons::conv_error& e)
{
std::cout << e.what() << "\n";
}
}
```
Output:
```
Cannot convert to string
```
|