I know I can use something like MessageBox.Show("some error")
but I'm talking about an error that occurs at some lower level in my code that has no business tossing up a MessageBox or any other GUI elements.
I'm building an RSS Client and I have a class which manages the various feeds (lets say FeedManager
) which is just a wrapper for a list at this point. Now this class calls on another class for data access. So anytime someone in the GUI wants to save the feeds, the GUI simply calls FeedManager.SaveFeeds()
which processes the feeds and saves them to a file, database, etc. So I attempt to save to a file and something bad happens (either something I coded for or an exception). So now I'm at least 3 levels deep, GUI
-> FeedManager
-> SomeDataAccessLayer
, and I want to display a message to the user like "Hey, that file was not found" or "You don't have permission to write to that location", etc...
How should I go about this? Throwing up a MessageBox
from the data access layer blatantly couples that component to the GUI. Having all methods return strings with any error messages seems silly as well.