Skip to content

Commit

Permalink
done changes in try block
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavankumar07s committed Nov 14, 2024
1 parent 9de1e58 commit 5f1deb1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,39 +152,46 @@ auto main(int argc, char *argv[]) noexcept -> int {
const std::vector<std::string> 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()
Expand All @@ -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 "
Expand Down

0 comments on commit 5f1deb1

Please sign in to comment.