Skip to content

Show error message upon error opening log file #2

Description

@xrobin

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

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

# Run CifCheck
CifCheck -f invalid.cif -dictSdb /path/to/mmcif_pdbx_v50.sdb

Observation

Command runs successfully, no error display, exit code 0, no diagnostic file invalid.cif-diag.log

Expected output

This should have displayed an error and, preferably, exited with a non 0 exit code.

Proposed solution

I opened a pull request in rcsb/cpp-cif-file#1 with a proposed fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions