Repository navigation
Implementation of suggestions arising from pmslavin's review - #16
OliverWoolland wants to merge 3 commits into
Conversation
pmslavin
left a comment
There was a problem hiding this comment.
Builds and tests pass. Looks good overall; I've added a few minor comments which are mostly questions and clarifications.
| return "Failed to parse JSON from file: {}. Error: {}"; | ||
| case ErrorCode::InvalidCrateStructure: | ||
| return "Invalid RO-Crate structure: missing '@context' or '@graph' fields."; | ||
| case ErrorCode::EntityMissingIdField: |
There was a problem hiding this comment.
Is this different from ErrorCode::EntityMissingId on L55 above?
| updateProperties(entity, entityJson); | ||
| entity = crate.getEntity(entityId); | ||
| crate.updateProperties(entity, entityJson); | ||
| } catch (const std::runtime_error&) { |
There was a problem hiding this comment.
std::runtime_error is a broad category of exception to catch here; is there a narrower exception that more closely corresponds to the Entity not existing but excludes the various other situations that can give rise to std::runtime_error?
Or can the presence of the Entity in the register be tested directly without requiring try/catch?
| FetchContent_Declare(Catch2 | ||
| GIT_REPOSITORY https://github.com/catchorg/Catch2.git | ||
| GIT_TAG v3.16.0 | ||
| FIND_PACKAGE_ARGS 3 |
There was a problem hiding this comment.
Not important and probably harmless either way, but does FIND_PACKAGE_ARGS do anything here when an explicit GIT_TAG has been provided?
Discussion thread documenting suggested changes here: #9
Major changes:
Deferred:
Copilot summary
This pull request introduces several improvements and refactorings to the RO-Crate C++ library. The most significant changes include the introduction of a centralized error handling mechanism, improved error messages, and a switch to using unordered maps for better performance. Additionally, the CMake configuration has been updated to use a newer version and to fetch Catch2 via
FetchContentfor testing. The serialization and deserialization logic for RO-Crate entities has also been refactored for clarity and robustness.Error handling improvements:
ErrorCodeenum and a centralizederror_messagefunction to standardize and clarify error messages throughout the codebase. All exceptions now use these error codes and message templates, often withstd::formatfor dynamic values. [1] [2] [3] [4] [5] [6] [7]Performance and data structure updates:
std::mapwithstd::unordered_mapfor entity and property storage to improve lookup performance inPropertiesandEntityRegister. [1] [2]Serialization and deserialization refactor:
to_jsonandfrom_jsonfunctions, improving code clarity and separation of concerns. Error handling for file I/O and JSON parsing is now more robust and uses the new error handling system. [1] [2]Build system improvements:
find_packagetoFetchContent, ensuring consistent and up-to-date dependency management for tests. [1] [2]These changes collectively improve maintainability, reliability, and performance of the RO-Crate library.