In my file repository, I will throw the following exceptions when the InsertFile()
method is called:
- When the upload file size limit is exceeded
- When the storage capacity is exceeded
At the moment I am just throwing an ApplicationException
with the relevant message:
public void InsertFile(HttpPostedFile uploadedFile)
{
if (uploadedFile.ContentLength > FileSizeLimit)
{
throw new ApplicationException("File size limit exceeded.");
}
if (uploadedFile.ContentLength + FileStorageUsage > FileStorageCapacity)
{
throw new ApplicationException("File storage capacity exceeded.");
}
// ...
}
Questions:
Are there better exception classes that I should be using here?
Or should I be creating my own custom exceptions by deriving from ApplicationException
?