Added FatalError function which conditionally handles an error