Implemented middleware that catches write exceptions during read-only mode (fixes #86).