refactored error and flash handling into partials