Better error catching.
Merge bug25722 (again)