[bug] Fix misleading log message when os.WriteFile fails in export path (#9)#10
Merged
Merged
Conversation
Distinguish the JSON serialization error from the file write error so users can tell which stage failed: the first branch now logs "Error serializing graph to JSON" and the second logs "Error writing graph to file <path>", instead of both reporting "Error exporting graph to file".
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.
Linked Issue
Closes #9
Root Cause
Two adjacent error branches in
main.go(the JSON-serialization step and the file-write step) emitted the same log message:"Error exporting graph to file: %s". The wording was carried over by copy-paste; it correctly described the surrounding context but not the specific failure. Users seeing the message could not tell whether the in-memory marshaling (og.ExportJSON) or the filesystem write (os.WriteFile) had failed, which made diagnosis of permission/path/disk issues unnecessarily difficult.Fix Description
Differentiate the two messages:
og.ExportJSONfailure now logs"Error serializing graph to JSON: %s".os.WriteFilefailure now logs"Error writing graph to file <outputFile>: %s", including the destination path so the user immediately knows what file the write was targeting.No other code paths reference the messages.
How Verified
Static: the two error branches in
main.goare the only places that emitted the original string; both have been replaced with distinct, more specific messages, and the surrounding control flow is unchanged.Runtime:
go buildsucceeds. Help output and normal connection path are unchanged.Test Coverage
None: the change is a log-string substitution with no behavioral effect; no test infrastructure exists in the repository.
Scope of Change
main.go