If i have an interface, which i add comments to to identify that a specific exception will be thrown, is it ok for implementing classes to throw different exceptions?
A (bad) example is:
public interface IWidgetWorker {
/// <summary>
/// Do the work required for the specified work id.
/// </summary>
/// <param name="workId">The id of the piece of work to do</param>
/// <exception cref="ArgumentException">Thrown if workId is empty</exception>
public void DoWork(Guid workId);
}
public class DatabaseWidgetWorker : IWidgetWorker {
public void DoWork(Guid workId) {
// throw some database related exception
}
}
public class WebWidgetWorker : IWidgetWorker {
public void DoWork(Guid workId) {
// throw some web related exception
}
}
Maybe i add a WidgetWorkerException
class? Where do i document what the specific exceptions that the implementing classes might throw?