Replacing on error instead of crashing