Fix #1203 by catching the boost exception thrown on error