From 8594a7e568b1b53c608737b9bff46ad615cd5a07 Mon Sep 17 00:00:00 2001 From: Ritabrata Ghosh <76sonali40@gmail.com> Date: Thu, 5 Feb 2026 22:44:29 +0530 Subject: [PATCH 1/2] exit code 3 added --- .vscode/c_cpp_properties.json | 19 +++++++++++ src/command_fmt.cc | 16 ++++----- src/command_lint.cc | 32 ++++++------------ src/command_metaschema.cc | 13 +++----- src/command_validate.cc | 61 +++++++++++++---------------------- 5 files changed, 61 insertions(+), 80 deletions(-) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..ea2ba9da --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "c17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-x64", + "compileCommands": [ + "/mnt/d/OpenSource/gsoc/sourcemeta/jsonschema/build/compile_commands.json" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/src/command_fmt.cc b/src/command_fmt.cc index f2c2fa42..fd65361a 100644 --- a/src/command_fmt.cc +++ b/src/command_fmt.cc @@ -72,22 +72,18 @@ auto sourcemeta::jsonschema::fmt(const sourcemeta::core::Options &options) } } } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw FileError(entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { - throw FileError(entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw FileError< - sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( - entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError(entry.first, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw FileError( - entry.first); + throw Fail{3}; } catch (const sourcemeta::core::SchemaError &error) { - throw FileError(entry.first, error.what()); + throw Fail{3}; } } diff --git a/src/command_lint.cc b/src/command_lint.cc index 56390a23..16ddf6a5 100644 --- a/src/command_lint.cc +++ b/src/command_lint.cc @@ -276,37 +276,31 @@ auto sourcemeta::jsonschema::lint(const sourcemeta::core::Options &options) std::cerr << "\n"; } - throw FileError< - sourcemeta::blaze::CompilerReferenceTargetNotSchemaError>( - entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaKeywordError &error) { if (printed_progress) { std::cerr << "\n"; } - throw FileError(entry.first, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { if (printed_progress) { std::cerr << "\n"; } - throw FileError(entry.first, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { if (printed_progress) { std::cerr << "\n"; } - throw FileError( - entry.first); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { if (printed_progress) { std::cerr << "\n"; } - throw FileError( - entry.first, error); + throw Fail{3}; } catch (...) { if (printed_progress) { std::cerr << "\n"; @@ -380,21 +374,15 @@ auto sourcemeta::jsonschema::lint(const sourcemeta::core::Options &options) } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw FileError< - sourcemeta::blaze::CompilerReferenceTargetNotSchemaError>( - entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw FileError(entry.first, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { - throw FileError(entry.first, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw FileError( - entry.first); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError( - entry.first, error); + throw Fail{3}; } }); diff --git a/src/command_metaschema.cc b/src/command_metaschema.cc index c7bb78f4..279687e8 100644 --- a/src/command_metaschema.cc +++ b/src/command_metaschema.cc @@ -48,8 +48,7 @@ auto sourcemeta::jsonschema::metaschema( const auto dialect{ sourcemeta::core::dialect(entry.second, default_dialect_option)}; if (dialect.empty()) { - throw FileError( - entry.first); + throw Fail{3}; } const auto metaschema{sourcemeta::core::metaschema( @@ -111,16 +110,12 @@ auto sourcemeta::jsonschema::metaschema( } } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw FileError( - entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw FileError< - sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( - entry.first, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError(entry.first, - error); + throw Fail{3}; } } diff --git a/src/command_validate.cc b/src/command_validate.cc index 66001bb7..79fcf39c 100644 --- a/src/command_validate.cc +++ b/src/command_validate.cc @@ -178,30 +178,23 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options) custom_resolver, dialect, schema_default_id); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaReferenceError &error) { - throw FileError( - schema_path, std::string{error.identifier()}, error.location(), - error.what()); + throw Fail{3}; } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw FileError< - sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( - schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError(schema_path, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw FileError( - schema_path); + throw Fail{3}; } catch (const sourcemeta::core::SchemaError &error) { - throw FileError(schema_path, error.what()); + throw Fail{3}; } catch ( const sourcemeta::core::SchemaReferenceObjectResourceError &error) { - throw FileError( - schema_path, error.identifier()); + throw Fail{3}; } }()}; @@ -212,21 +205,18 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options) frame.analyse(bundled, sourcemeta::core::schema_walker, custom_resolver, dialect, schema_default_id); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch ( const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw FileError( - schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError(schema_path, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw FileError( - schema_path); + throw Fail{3}; } catch (const sourcemeta::core::SchemaError &error) { - throw FileError(schema_path, error.what()); + throw Fail{3}; } const auto schema_template{[&]() { @@ -235,29 +225,22 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options) options); } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw FileError( - schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaFrameError &error) { - throw FileError(schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaReferenceError &error) { - throw FileError( - schema_path, std::string{error.identifier()}, error.location(), - error.what()); + throw Fail{3}; } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw FileError< - sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( - schema_path, error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw FileError(schema_path, - error); + throw Fail{3}; } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw FileError( - schema_path); + throw Fail{3}; } catch (const sourcemeta::core::SchemaError &error) { - throw FileError(schema_path, error.what()); + throw Fail{3}; } }()}; From f826ca957feda619bc25d0da4ea10c47173c9409 Mon Sep 17 00:00:00 2001 From: RitoG09 <76sonali40@gmail.com> Date: Thu, 5 Feb 2026 20:31:22 +0000 Subject: [PATCH 2/2] exit code 3 added:01 --- .vscode/c_cpp_properties.json | 19 ----------- src/command_fmt.cc | 16 +++++---- src/command_lint.cc | 32 ++++++++++++------ src/command_metaschema.cc | 13 +++++--- src/command_validate.cc | 62 ++++++++++++++++++++++------------- src/error.h | 6 ++-- 6 files changed, 84 insertions(+), 64 deletions(-) delete mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json deleted file mode 100644 index ea2ba9da..00000000 --- a/.vscode/c_cpp_properties.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "configurations": [ - { - "name": "Linux", - "includePath": [ - "${workspaceFolder}/**" - ], - "defines": [], - "compilerPath": "/usr/bin/gcc", - "cStandard": "c17", - "cppStandard": "gnu++17", - "intelliSenseMode": "linux-gcc-x64", - "compileCommands": [ - "/mnt/d/OpenSource/gsoc/sourcemeta/jsonschema/build/compile_commands.json" - ] - } - ], - "version": 4 -} \ No newline at end of file diff --git a/src/command_fmt.cc b/src/command_fmt.cc index fd65361a..f2c2fa42 100644 --- a/src/command_fmt.cc +++ b/src/command_fmt.cc @@ -72,18 +72,22 @@ auto sourcemeta::jsonschema::fmt(const sourcemeta::core::Options &options) } } } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw Fail{3}; + throw FileError(entry.first, error); } catch (const sourcemeta::core::SchemaFrameError &error) { - throw Fail{3}; + throw FileError(entry.first, error); } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw Fail{3}; + throw FileError< + sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( + entry.first, error); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError(entry.first, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw Fail{3}; + throw FileError( + entry.first); } catch (const sourcemeta::core::SchemaError &error) { - throw Fail{3}; + throw FileError(entry.first, error.what()); } } diff --git a/src/command_lint.cc b/src/command_lint.cc index 16ddf6a5..003dc3f8 100644 --- a/src/command_lint.cc +++ b/src/command_lint.cc @@ -276,31 +276,37 @@ auto sourcemeta::jsonschema::lint(const sourcemeta::core::Options &options) std::cerr << "\n"; } - throw Fail{3}; + throw FileError< + sourcemeta::blaze::CompilerReferenceTargetNotSchemaError>( + entry.first, error); } catch (const sourcemeta::core::SchemaKeywordError &error) { if (printed_progress) { std::cerr << "\n"; } - throw Fail{3}; + throw FileError(entry.first, + error); } catch (const sourcemeta::core::SchemaFrameError &error) { if (printed_progress) { std::cerr << "\n"; } - throw Fail{3}; + throw FileError(entry.first, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { if (printed_progress) { std::cerr << "\n"; } - throw Fail{3}; + throw FileError( + entry.first); } catch (const sourcemeta::core::SchemaResolutionError &error) { if (printed_progress) { std::cerr << "\n"; } - throw Fail{3}; + throw FileError( + entry.first, error); } catch (...) { if (printed_progress) { std::cerr << "\n"; @@ -374,15 +380,21 @@ auto sourcemeta::jsonschema::lint(const sourcemeta::core::Options &options) } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw Fail{3}; + throw FileError< + sourcemeta::blaze::CompilerReferenceTargetNotSchemaError>( + entry.first, error); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw Fail{3}; + throw FileError(entry.first, + error); } catch (const sourcemeta::core::SchemaFrameError &error) { - throw Fail{3}; + throw FileError(entry.first, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw Fail{3}; + throw FileError( + entry.first); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError( + entry.first, error); } }); diff --git a/src/command_metaschema.cc b/src/command_metaschema.cc index 279687e8..c7bb78f4 100644 --- a/src/command_metaschema.cc +++ b/src/command_metaschema.cc @@ -48,7 +48,8 @@ auto sourcemeta::jsonschema::metaschema( const auto dialect{ sourcemeta::core::dialect(entry.second, default_dialect_option)}; if (dialect.empty()) { - throw Fail{3}; + throw FileError( + entry.first); } const auto metaschema{sourcemeta::core::metaschema( @@ -110,12 +111,16 @@ auto sourcemeta::jsonschema::metaschema( } } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw Fail{3}; + throw FileError( + entry.first, error); } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw Fail{3}; + throw FileError< + sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( + entry.first, error); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError(entry.first, + error); } } diff --git a/src/command_validate.cc b/src/command_validate.cc index 79fcf39c..9e50c89d 100644 --- a/src/command_validate.cc +++ b/src/command_validate.cc @@ -178,23 +178,30 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options) custom_resolver, dialect, schema_default_id); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch (const sourcemeta::core::SchemaFrameError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch (const sourcemeta::core::SchemaReferenceError &error) { - throw Fail{3}; + throw FileError( + schema_path, std::string{error.identifier()}, error.location(), + error.what()); } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw Fail{3}; + throw FileError< + sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( + schema_path, error); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError(schema_path, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw Fail{3}; + throw FileError( + schema_path); } catch (const sourcemeta::core::SchemaError &error) { - throw Fail{3}; + throw FileError(schema_path, error.what()); } catch ( const sourcemeta::core::SchemaReferenceObjectResourceError &error) { - throw Fail{3}; + throw FileError( + schema_path, error.identifier()); } }()}; @@ -205,42 +212,53 @@ auto sourcemeta::jsonschema::validate(const sourcemeta::core::Options &options) frame.analyse(bundled, sourcemeta::core::schema_walker, custom_resolver, dialect, schema_default_id); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch (const sourcemeta::core::SchemaFrameError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch ( const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw Fail{3}; + throw FileError( + schema_path, error); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError(schema_path, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw Fail{3}; + throw FileError( + schema_path); } catch (const sourcemeta::core::SchemaError &error) { - throw Fail{3}; + throw FileError(schema_path, error.what()); } + const auto schema_template{[&]() { try { return get_schema_template(bundled, custom_resolver, frame, fast_mode, options); } catch ( const sourcemeta::blaze::CompilerReferenceTargetNotSchemaError &error) { - throw Fail{3}; + throw FileError( + schema_path, error); } catch (const sourcemeta::core::SchemaKeywordError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch (const sourcemeta::core::SchemaFrameError &error) { - throw Fail{3}; + throw FileError(schema_path, error); } catch (const sourcemeta::core::SchemaReferenceError &error) { - throw Fail{3}; + throw FileError( + schema_path, std::string{error.identifier()}, error.location(), + error.what()); } catch (const sourcemeta::core::SchemaRelativeMetaschemaResolutionError &error) { - throw Fail{3}; + throw FileError< + sourcemeta::core::SchemaRelativeMetaschemaResolutionError>( + schema_path, error); } catch (const sourcemeta::core::SchemaResolutionError &error) { - throw Fail{3}; + throw FileError(schema_path, + error); } catch (const sourcemeta::core::SchemaUnknownBaseDialectError &) { - throw Fail{3}; + throw FileError( + schema_path); } catch (const sourcemeta::core::SchemaError &error) { - throw Fail{3}; + throw FileError(schema_path, error.what()); } }()}; diff --git a/src/error.h b/src/error.h index e1c8d685..ecb41a36 100644 --- a/src/error.h +++ b/src/error.h @@ -462,7 +462,7 @@ inline auto try_catch(const sourcemeta::core::Options &options, &error) { const auto is_json{options.contains("json")}; print_exception(is_json, error); - return EXIT_FAILURE; + return 3; } catch (const FileError &error) { const auto is_json{options.contains("json")}; print_exception(is_json, error); @@ -476,7 +476,7 @@ inline auto try_catch(const sourcemeta::core::Options &options, } } - return EXIT_FAILURE; + return 3; } catch ( const FileError &error) { const auto is_json{options.contains("json")}; @@ -491,7 +491,7 @@ inline auto try_catch(const sourcemeta::core::Options &options, "`--default-dialect/-d`\n"; } - return EXIT_FAILURE; + return 3; } catch (const FileError &error) { const auto is_json{options.contains("json")}; print_exception(is_json, error);