Yes, use a ViewController, it is better than a simple view. Your message could have actions like buttons.
To avoid too many code duplications, you may use a mixin :
protocol ErrorDisplay {
func display(_ error: Error)
}
extension ErrorDisplay where Self: UIViewController {
func display(_ error: Error) {
let viewController = ErrorViewController(error: error)
// You could also add it as a child view controller rather than presenting it,
// if you want to add its view in the current hierarchy
present(viewController, animated: true, completion: nil)
}
}
And implement the protocol in each view controller that wishes to display a error.
extension LoginViewController : ErrorDisplay {}
extension SettingsViewController : ErrorDisplay {}
...