Modernize the error handling of the Materialize function.