Add error handling logic to null out the context if an error occurred during initialization