c# - catching exceptions while following SOLID principles in winrt -


 public async task<storagefile> getfile( string filename )     {         // throw new notimplementedexception();         var _folder = applicationdata.current.localfolder;         try         {           var _file = await _folder.getfileasync(filename);             return _file;         }         catch (filenotfoundexception)         {             //notify user exception.         }         return null;     } 

this method in class retrieves file local storage. want notify user exception. if try message box in catch statement braking solid's first rule of single responsibility.

how should setup class other handler class can catch exceptions , take required action? first thoughts event handlers, there better technique?

public async task<storagefile> getfile( string filename )     {         // throw new notimplementedexception();         var _folder = applicationdata.current.localfolder;         try         {           var _file = await _folder.getfileasync(filename);             return _file;         }         catch         {            throw;         }         return null;     } 

instead of catching exception here throw controller called it. sure have try{}catch{} surrounding call method , can handle exception there (i.e. show message box).


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -