namespace Ringtoets.Piping.IO.Builders { /// /// Class to help create consistent file reader error messages. /// public class FileReaderErrorMessageBuilder { private readonly string filePath; private string location; private string subject; /// /// Initializes a new instance of the class. /// /// The file path to the file where the error occurred. public FileReaderErrorMessageBuilder(string filePath) { this.filePath = filePath; } /// /// Builds the specified error message. /// /// The message about the error that has occurred. /// The full error message. public string Build(string errorMessage) { return string.Format("Fout bij het lezen van bestand '{0}'{1}{2}: {3}", filePath, location ?? string.Empty, subject ?? string.Empty, errorMessage); } /// /// Adds file location information to the error message. /// /// The location description. /// The builder being configured. /// line 7 public FileReaderErrorMessageBuilder WithLocation(string locationDescription) { location = " " + locationDescription; return this; } /// /// Adds the subject where the error occurred to the error message. /// /// The subject description. /// The builder being configured. /// soil profile 'blabla' public FileReaderErrorMessageBuilder WithSubject(string subjectDescription) { subject = string.Format(" ({0})", subjectDescription); return this; } } }