I encountered this error unexpectedly. How can I find the solution to solve it? This is where error occured
$resultPage->getLayout()->getBlock('messages')->setEscapeMessageFlag(true);
PHP Fatal error: Uncaught Error: Call to a member function setEscapeMessageFlag() on boolean in /var/www/html/magento2/vendor/magento/module-customer/Controller/Account/Edit.php:83\n Stack trace:\n
#0 /var/www/html/magento2/var/generation/Magento/Customer/Controller/Account/Edit/Interceptor.php(24): Magento\Customer\Controller\Account\Edit->execute()\n
#1 /var/www/html/magento2/vendor/magento/framework/App/Action/Action.php(102): Magento\Customer\Controller\Account\Edit\Interceptor->execute()\n
#2 /var/www/html/magento2/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))\n
#3 /var/www/html/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Customer\Controller\Account\Edit\Interceptor->___callParent('dispatch', Array)\n
#4 /var/www/html/magento2/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Custome...', 'dispatch', Object(Magento\Customer\Con in /var/www/html/magento2/vendor/magento/module-customer/Controller/Account/Edit.php on line 83