DG: FEAT: Propagate error messages to the backend - #29
Merged
Conversation
mberz
commented
Aug 20, 2026
Contributor
- raised Exceptions are written to the json file returned to the backend
- Uses FEAT: Propagate error messages from simulation methods to database backend#107
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the DG method container CLI entrypoint to capture runtime exceptions and propagate structured error information back to the backend via the JSON result file, aligning with backend changes in choras-org/backend#107.
Changes:
- Wrap DG simulation execution with exception handling that writes an
errorobject into the JSON result file. - Ensure the container exits with status code
1on failure so the backend can detect unsuccessful runs.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+15
to
39
| # Initialize Gmsh before running the simulation | ||
| gmsh.initialize() | ||
| try: | ||
| dg_method_object = DGMethod(json_file_path) | ||
| dg_method_object.run_simulation() | ||
| finally: | ||
| # Ensure that gmsh is finalized | ||
| gmsh.finalize() | ||
|
|
||
| # Outer except to ensure gmsh is finalized above before sys.exit is called | ||
| except Exception as e: | ||
| # Write error to result JSON so backend can read it | ||
| with open(json_file_path) as f: | ||
| data = json.load(f) | ||
| data['error'] = {'type': type(e).__name__, 'message': str(e)} | ||
| with open(json_file_path, 'w') as f: | ||
| json.dump(data, f, indent=4) | ||
|
|
||
| # Ensure the container exits with exit code 1 to indicate failure | ||
| # The status code is used by the backend to determine if the simulation | ||
| # was successful or not. | ||
| sys.exit(1) | ||
|
|
||
| # Save the results to a separate file | ||
| dg_method_object.save_results() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.