better error handling on unwritable statefiles/dirs