I have a method which takes a directory path as a string. In the beginning of the method it checks if this path exists and if not it should throw an exception. I'm thinking it should maybe throw a DirectoryNotFoundException
or something instead of a less specific ArgumentException
.
I read the msdn documentation of that DirectoryNotFoundException
and it says that
DirectoryNotFoundException
uses theHRESULT COR_E_DIRECTORYNOTFOUND
which has the value0x80070003
.
I don't know what that means exactly, and it looks a bit scary... should I still throw that exception, or should I stick to a regular ArgumentException
? Or should I stick to the ArgumentException
simply because it is an argument I am complaining about? Or?
public void MakeFunOf(string path)
{
if(!Directory.Exists(path))
throw new WhatException();
TellJokeAbout(path);
PointAndLaughAt(path);
}