diff --git a/src/main.cc b/src/main.cc index 60efeae..c56a563 100644 --- a/src/main.cc +++ b/src/main.cc @@ -152,39 +152,46 @@ auto main(int argc, char *argv[]) noexcept -> int { const std::vector arguments{argv + std::min(2, argc), argv + argc}; return jsonschema_main(program, command, arguments); + } catch (const sourcemeta::jsontoolkit::SchemaReferenceError &error) { std::cerr << "error: " << error.what() << "\n " << error.id() << "\n at schema location \""; sourcemeta::jsontoolkit::stringify(error.location(), std::cerr); std::cerr << "\"\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::SchemaResolutionError &error) { std::cerr << "error: " << error.what() << "\n at " << error.id() << "\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::SchemaError &error) { std::cerr << "error: " << error.what() << "\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::SchemaVocabularyError &error) { std::cerr << "error: " << error.what() << "\n " << error.uri() << "\n\nTo request support for it, please open an issue " - "at\nhttps://github.com/sourcemeta/jsonschema\n"; + << "at\nhttps://github.com/sourcemeta/jsonschema\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::URIParseError &error) { std::cerr << "error: " << error.what() << " at column " << error.column() << "\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::FileParseError &error) { std::cerr << "error: " << error.what() << " at line " << error.line() << " and column " << error.column() << "\n " << std::filesystem::weakly_canonical(error.path()).string() << "\n"; return EXIT_FAILURE; + } catch (const sourcemeta::jsontoolkit::ParseError &error) { std::cerr << "error: " << error.what() << " at line " << error.line() << " and column " << error.column() << "\n"; return EXIT_FAILURE; + } catch (const std::filesystem::filesystem_error &error) { - // See https://en.cppreference.com/w/cpp/error/errc if (error.code() == std::errc::no_such_file_or_directory) { std::cerr << "error: " << error.code().message() << "\n " << std::filesystem::weakly_canonical(error.path1()).string() @@ -197,11 +204,12 @@ auto main(int argc, char *argv[]) noexcept -> int { } else { std::cerr << "error: " << error.what() << "\n"; } - return EXIT_FAILURE; + } catch (const std::runtime_error &error) { std::cerr << "error: " << error.what() << "\n"; return EXIT_FAILURE; + } catch (const std::exception &error) { std::cerr << "unexpected error: " << error.what() << "\nPlease report it at "