Skip to content

Instantly share code, notes, and snippets.

@codereflection
Created November 28, 2011 20:05
Show Gist options
  • Save codereflection/1401802 to your computer and use it in GitHub Desktop.
Save codereflection/1401802 to your computer and use it in GitHub Desktop.
I don't like this pattern of throwing exceptions
public DirectoryInfo GetDestinationFor(string fileName)
{
Log.InfoFormat("Getting destination for {0}", fileName);
var result = paths.FirstOrDefault(x => x.Key.IsMatch(fileName));
if (result.Key != null)
{
Log.InfoFormat("Destination for {0} is {1}", fileName, result.Value);
return result.Value;
}
throw new FileDestinationPickerException(string.Format("Cannot find destination for '{0}'", fileName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment