/// ------------------------------------------------------------------------------------ /// <summary> /// Construct an import exception whose message contains a description of the error, /// including the offending segment, optional additional information, and BCV details. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="sParam">Parameter to put into error message if it is a format string /// (can be null)</param> /// <param name="moreInfo">Details about the specific problem</param> /// <param name="book">3-letter Book ID</param> /// <param name="chapter">Chapter number</param> /// <param name="verse">Verse number</param> /// <param name="fInterleavedImport"></param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string sParam, string moreInfo, string book, string chapter, string verse, bool fInterleavedImport) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); if (sParam != null) { m_message = string.Format(m_message, sParam); } if (!string.IsNullOrEmpty(moreInfo)) { m_message += Environment.NewLine + moreInfo; } string sBcvDetails = BCVDetails(book, chapter, verse); if (!string.IsNullOrEmpty(sBcvDetails)) { m_message += Environment.NewLine + sBcvDetails; } m_fInterleavedImport = fInterleavedImport; }
private void DisplayImportError(SUE_ErrorCode errorCode, string sParam1, string sParam2, string msgDetails) { string msgTemplate; string topic; bool includeDetails; ScriptureUtilsException.GetErrorMsgAndHelpTopic(errorCode, out msgTemplate, out topic, out includeDetails); string message; if (!string.IsNullOrEmpty(sParam1) && !string.IsNullOrEmpty(sParam2)) { message = string.Format(msgTemplate, sParam1, sParam2, msgDetails); } else if (!string.IsNullOrEmpty(sParam1)) { message = string.Format(msgTemplate, sParam1, msgDetails); } else { message = string.Format(msgTemplate, msgDetails); } // TODO-Linux: Help is not implemented in Mono MessageBox.Show(this, message, ScriptureUtilsException.GetResourceString("kstidXmlImportErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0, m_helpTopicProvider.HelpFile, HelpNavigator.Topic, topic); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a Scripture utils exception. These are used for import errors. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="book">3-letter Book ID</param> /// <param name="chapter">Chapter number</param> /// <param name="verse">Verse number</param> /// <param name="fInterleavedImport"></param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, int lineNumber, string lineContents, string book, string chapter, string verse, bool fInterleavedImport) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); m_message += Environment.NewLine + Environment.NewLine + FormatErrorDetails(fileName, fIncludeLineInfo, lineNumber, lineContents, book, chapter, verse); m_fInterleavedImport = fInterleavedImport; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Displays the "Unable to Import" message box. /// </summary> /// ----------------------------------------------------------------------------------- private void DisplayImportError(SUE_ErrorCode errorCode, string msgDetails) { string msgTemplate; string topic; bool includeDetails; ScriptureUtilsException.GetErrorMsgAndHelpTopic(errorCode, out msgTemplate, out topic, out includeDetails); MessageBox.Show(this, string.Format(msgTemplate, msgDetails), ScriptureUtilsException.GetResourceString("kstidImportErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0, FwApp.App.HelpFile, HelpNavigator.Topic, topic); }
///// ------------------------------------------------------------------------------------ ///// <summary> ///// Initializes a new instance of the <see cref="ScriptureUtilsException"/> class. ///// </summary> ///// <param name="errorCode">The error code representing the import problem.</param> ///// <param name="fileName">Name of the file.</param> ///// <param name="lineText">The text in the line with the error.</param> ///// <param name="currentRef">The reference where the error occurred.</param> ///// ------------------------------------------------------------------------------------ //public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, string lineText, // BCVRef currentRef) //{ // bool fIncludeLineInfo; // ErrorCode = errorCode; // GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); // if (!string.IsNullOrEmpty(lineText)) // m_message += Environment.NewLine + lineText; // string sBcvDetails = BCVDetails(BCVRef.NumberToBookCode(currentRef.Book), // currentRef.Chapter.ToString(), currentRef.Verse.ToString()); // if (!string.IsNullOrEmpty(sBcvDetails)) // m_message += Environment.NewLine + sBcvDetails; //} /// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="ScriptureUtilsException"/> class /// appropriate for reporting third-party exceptions that occur during importing. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="e">An Exception</param> /// ----------------------------------------------------------------------------------- public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, Exception e) : base("", e) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); m_message += Environment.NewLine + string.Format(GetResourceString("kstidImportErrorFileDetails"), fileName); Exception innerException = InnerException; while (innerException != null) { m_message += Environment.NewLine + innerException.Message; innerException = innerException.InnerException; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct an import exception whose message contains a description of the error, /// including the offending segment, optional additional information, and BCV details. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="moreInfo">Details about the specific problem</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="scrRef">scripture reference where the error occurred</param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string moreInfo, string fileName, int lineNumber, string lineContents, BCVRef scrRef) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); // Add file and Scripture reference information. m_message += Environment.NewLine + Environment.NewLine + FormatErrorDetails(fileName, fIncludeLineInfo, lineNumber, lineContents, BCVRef.NumberToBookCode(scrRef.Book), scrRef.Chapter.ToString(), scrRef.Verse.ToString()); // Add any details about the error. if (!string.IsNullOrEmpty(moreInfo)) { m_message += Environment.NewLine + moreInfo; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a Scripture utils exception. These are used for import errors. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="scrRef">scripture reference where the error occurred</param> /// <param name="fInterleavedImport"></param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, int lineNumber, string lineContents, BCVRef scrRef, bool fInterleavedImport) : this(errorCode, fileName, lineNumber, lineContents, ScrReference.NumberToBookCode(scrRef.Book), scrRef.Chapter.ToString(), scrRef.Verse.ToString(), fInterleavedImport) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a Scripture utils exception. These are used for import errors. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="book">3-letter Book ID</param> /// <param name="chapter">Chapter number</param> /// <param name="verse">Verse number</param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, int lineNumber, string lineContents, string book, string chapter, string verse) : this(errorCode, fileName, lineNumber, lineContents, book, chapter, verse, false) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Interpret the error code and return an appropriate error message string and help /// topic URL. /// </summary> /// <param name="error">An error code</param> /// <param name="msg">A string containing a user-friendly explanation of the problem /// </param> /// <param name="topic">the correct help topic for the error</param> /// <param name="includeLineInfoInDetails">A flag indicating whether caller should /// include the reported line number (if any) when formatting the details for the user. /// (For some errors the line number, although reported by TESO, is meaningless.)</param> /// ------------------------------------------------------------------------------------ static public void GetErrorMsgAndHelpTopic(SUE_ErrorCode error, out string msg, out string topic, out bool includeLineInfoInDetails) { includeLineInfoInDetails = true; topic = "/Beginning_Tasks/Import_Standard_Format/Unable_to_Import"; string stidErrorMsg = null; switch (error) { case SUE_ErrorCode.FileError: stidErrorMsg = "kstidImportFileError"; topic += "/File_error_occurred.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.MissingBook: stidErrorMsg = "kstidImportMissingBookAndChapterMarkers"; topic += "/No_book_or_chapter_markers_in_file.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.MissingChapterNumber: stidErrorMsg = "kstidImportVerseNoChapter"; topic += "/Verse_number_without_a_preceding_chapter_number.htm"; break; case SUE_ErrorCode.ChapterWithNoBook: stidErrorMsg = "kstidImportChapterNoBook"; topic += "/Chapter_not_part_of_a_book.htm"; break; case SUE_ErrorCode.UnexcludedDataBeforeIdLine: stidErrorMsg = "kstidImportUnexcludedDataBeforeId"; topic += "/Unexpected_field_precedes_the_id_identification_field.htm"; break; case SUE_ErrorCode.NoChapterNumber: // No chapter marker in a book that requires one stidErrorMsg = "kstidImportBooksNoChapters"; topic += "/Missing_chapter_marker.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.InvalidBookID: stidErrorMsg = "kstidImportInvalidBook"; topic += "/Invalid_book_code.htm"; break; case SUE_ErrorCode.InvalidChapterNumber: // chapter numbers {vernacular or not} are non-numeric stidErrorMsg = "kstidImportInvalidChapterNumber"; topic += "/Invalid_chapter_number.htm"; break; case SUE_ErrorCode.InvalidVerseNumber: // verse numbers {vernacular or not} are non-numeric or // are an invalid verse range stidErrorMsg = "kstidImportInvalidVerseNumber"; topic += "/Invalid_verse_number.htm"; break; case SUE_ErrorCode.InvalidPictureParameters: //The picture parameters are invalid stidErrorMsg = "kstidImportErrorPictureFileName"; topic += "/Invalid_figure_parameters.htm"; break; case SUE_ErrorCode.InvalidPictureFilename: //The picture filename is invalid stidErrorMsg = "kstidImportErrorPictureFileName"; topic += "/Invalid_figure_file_name_property.htm"; break; case SUE_ErrorCode.VerseWithNoBook: // A verse was encountered without a book id stidErrorMsg = "kstidImportVerseNotPartOfBook"; topic += "/Verse_not_part_of_a_book.htm"; break; case SUE_ErrorCode.BadFigure: // A badly-formed \fig entry was encountered stidErrorMsg = "kstidImportBadFigure"; topic += "/Invalid_figure_parameters.htm"; break; case SUE_ErrorCode.IntroWithinScripture: stidErrorMsg = "kstidImportIntroWithinScripture"; topic += "/Book_introduction_within_Scripture_text.htm"; break; case SUE_ErrorCode.InvalidCharacterInMarker: stidErrorMsg = "kstidImportInvalidCharacterInMarker"; topic += "/Invalid_character_in_marker.htm"; break; case SUE_ErrorCode.BackTransStyleMismatch: stidErrorMsg = "kstidBTStyleMismatch"; topic += "_Back_Translation/Back_translation_does_not_correspond_to_the_preceding_vernacular_paragraph.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.BackTransParagraphMismatch: stidErrorMsg = "kstidBTParagraphMismatch"; topic += "_Back_Translation/Back_translation_does_not_correspond_to_a_vernacular_paragraph.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.BackTransTextNotPartOfParagraph: stidErrorMsg = "kstidBtTextNotPartofPara"; topic += "_Back_Translation/Back_translation_not_part_of_a_paragraph.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.BackTransMissingVernPara: stidErrorMsg = "kstidMissingVernParaForBT"; topic += "_Back_Translation/Back_translation_precedes_vernacular_fields_in_book.htm"; break; case SUE_ErrorCode.BackTransMissingVernBook: stidErrorMsg = "kstidMissingVernBookForBT"; topic += "_Back_Translation/No_corresponding_vernacular_book_for_back_translation.htm"; includeLineInfoInDetails = false; break; case SUE_ErrorCode.BackTransMissingVernFootnote: stidErrorMsg = "kstidMissingVernFootnoteForBT"; topic += "_Back_Translation/Back_translation_does_not_correspond_to_a_vernacular_footnote.htm"; break; case SUE_ErrorCode.BackTransMissingVernPicture: stidErrorMsg = "kstidBTNoCorrespondingPicture"; topic += "_Back_Translation/Back_translation_does_not_correspond_to_a_vernacular_picture.htm"; break; case SUE_ErrorCode.UnexpectedParagraph: stidErrorMsg = "kstidUnexpectedParagraph"; topic = ResourceHelper.NoHelpTopicURL; break; case SUE_ErrorCode.OxesMigrationFailed: stidErrorMsg = "kstidOxesMigrationFailed"; topic = ResourceHelper.NoHelpTopicURL; break; case SUE_ErrorCode.OxesValidationFailed: stidErrorMsg = "kstidOxesValidationFailed"; topic = ResourceHelper.NoHelpTopicURL; break; } msg = GetResourceString(stidErrorMsg); /* Remove from help files before deleting! */ // case ECERROR_VerseNoBook: // stidErrorMsg = "kstidImportVerseNotPartOfBook"; // topic += "Verse_not_part_of_a_book.htm"; // break; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct a Scripture utils exception. These are used for import errors. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="book">3-letter Book ID</param> /// <param name="chapter">Chapter number</param> /// <param name="verse">Verse number</param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string fileName, int lineNumber, string lineContents, string book, string chapter, string verse): this(errorCode, fileName, lineNumber, lineContents, book, chapter, verse, false) { }
private void DisplayImportError(SUE_ErrorCode errorCode, string sParam1, string sParam2, string msgDetails) { string msgTemplate; string topic; bool includeDetails; ScriptureUtilsException.GetErrorMsgAndHelpTopic(errorCode, out msgTemplate, out topic, out includeDetails); string message; if (!string.IsNullOrEmpty(sParam1) && !string.IsNullOrEmpty(sParam2)) message = string.Format(msgTemplate, sParam1, sParam2, msgDetails); else if (!string.IsNullOrEmpty(sParam1)) message = string.Format(msgTemplate, sParam1, msgDetails); else message = string.Format(msgTemplate, msgDetails); // TODO-Linux: Help is not implemented in Mono MessageBox.Show(this, message, ScriptureUtilsException.GetResourceString("kstidXmlImportErrorCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, 0, m_helpTopicProvider.HelpFile, HelpNavigator.Topic, topic); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct an import exception whose message contains a description of the error, /// including the offending segment, optional additional information, and BCV details. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="moreInfo">Details about the specific problem</param> /// <param name="fileName">file name where the error was encountered</param> /// <param name="lineNumber">line number in the file where the error occurred</param> /// <param name="lineContents">Contents of problematic line (or segment)</param> /// <param name="scrRef">scripture reference where the error occurred</param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string moreInfo, string fileName, int lineNumber, string lineContents, BCVRef scrRef) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); // Add file and Scripture reference information. m_message += Environment.NewLine + Environment.NewLine + FormatErrorDetails(fileName, fIncludeLineInfo, lineNumber, lineContents, BCVRef.NumberToBookCode(scrRef.Book), scrRef.Chapter.ToString(), scrRef.Verse.ToString()); // Add any details about the error. if (!string.IsNullOrEmpty(moreInfo)) m_message += Environment.NewLine + moreInfo; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Construct an import exception whose message contains a description of the error, /// including the offending segment, optional additional information, and BCV details. /// </summary> /// <param name="errorCode">numeric error code</param> /// <param name="sParam">Parameter to put into error message if it is a format string /// (can be null)</param> /// <param name="moreInfo">Details about the specific problem</param> /// <param name="book">3-letter Book ID</param> /// <param name="chapter">Chapter number</param> /// <param name="verse">Verse number</param> /// <param name="fInterleavedImport"></param> /// ------------------------------------------------------------------------------------ public ScriptureUtilsException(SUE_ErrorCode errorCode, string sParam, string moreInfo, string book, string chapter, string verse, bool fInterleavedImport) { bool fIncludeLineInfo; ErrorCode = errorCode; GetErrorMsgAndHelpTopic(errorCode, out m_message, out m_helpTopic, out fIncludeLineInfo); if (sParam != null) m_message = string.Format(m_message, sParam); if (!string.IsNullOrEmpty(moreInfo)) m_message += Environment.NewLine + moreInfo; string sBcvDetails = BCVDetails(book, chapter, verse); if (!string.IsNullOrEmpty(sBcvDetails)) m_message += Environment.NewLine + sBcvDetails; m_fInterleavedImport = fInterleavedImport; }