Skip to content

Show error message upon error opening log file - #1

Open
xrobin wants to merge 1 commit into
rcsb:masterfrom
xrobin:error_reporting
Open

Show error message upon error opening log file#1
xrobin wants to merge 1 commit into
rcsb:masterfrom
xrobin:error_reporting

Conversation

@xrobin

@xrobin xrobin commented May 29, 2026

Copy link
Copy Markdown

Summary

The CifCheck command fails silently when it cannot write to the *-diag.log file (eg if $PWD is read-only). ofstream::open() is unchecked and validation errors are lost. With no output and an exit code of 0, it looks exactly like the input file passed validation.

Steps to reproduce:

#  Create the test directory and a minimally invalid CIF file:
mkdir -p /tmp/test_mmcif
cat > /tmp/test_mmcif/invalid.cif << 'EOF'
data_test
_invalid_category.field value
EOF
# Check validation
CifCheck -f invalid.cif -dictSdb /path/to/mmcif_pdbx_v50.sdb
# Creates an output
cat invalid.cif-diag.log 
# ERROR - In block "test", category "invalid_category" is not defined in the reference file
# ERROR - In block "test", in category "invalid_category", item "field" is not defined in the reference file
# ERROR - In block "test", category "invalid_category" is not defined in the reference file
# ERROR - In block "test", in category "invalid_category", item "field" is not defined in the reference file

# Remove write permission on the directory:
rm invalid.cif-diag.log
chmod a-w /tmp/test_mmcif

# Run CifCheck again
CifCheck -f invalid.cif -dictSdb /path/to/mmcif_pdbx_v50.sdb
# Appears successful: no error displayed on stderr, no diagnostic file:
ls invalid.cif-diag.log
# ls: cannot access 'invalid.cif-diag.log': No such file or directory

Expected output

There should be some indication that the file invalid.cif-diag.log is absent not because the cif file is valid, but because CifCheck it failed to create it.

Changes

With this commit, a FileException is thrown in CifFile::DataChecking() if the diagnostic log cannot be opened or written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant