Skip to content

Commit

Permalink
back to normal
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavankumar07s committed Nov 14, 2024
1 parent ae3736f commit 177db63
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ auto jsonschema_main(const std::string &program, const std::string &command,
}
}

int main(int argc, char *argv[]) noexcept {
auto main(int argc, char *argv[]) noexcept -> int {
try {
std::string program{argv[0]};
std::string command = (argc > 1) ? argv[1] : "help";
std::vector<std::string> arguments{argv + std::min(2, argc), argv + argc};

const std::string program{argv[0]};
const std::string command{argc > 1 ? argv[1] : "help"};
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()
Expand All @@ -167,7 +167,7 @@ int main(int argc, char *argv[]) noexcept {
} 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()
Expand All @@ -184,6 +184,7 @@ int main(int argc, char *argv[]) noexcept {
<< " 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 @@ -196,6 +197,7 @@ int main(int argc, char *argv[]) noexcept {
} else {
std::cerr << "error: " << error.what() << "\n";
}

return EXIT_FAILURE;
} catch (const std::runtime_error &error) {
std::cerr << "error: " << error.what() << "\n";
Expand All @@ -206,4 +208,4 @@ int main(int argc, char *argv[]) noexcept {
<< "https://github.com/sourcemeta/jsonschema\n";
return EXIT_FAILURE;
}
}
}

0 comments on commit 177db63

Please sign in to comment.