/// <summary> /// Report firmware command errors to the user. /// </summary> /// <param name="command">The firmware-related command that failed.</param> /// <param name="errorMessage">The message generated from the command execution code.</param> /// <param name="exception">The exception that caused the error, if applicable.</param> /// <returns><c>true</c> if the error was reported to the user.</returns> internal static bool ErrorHandler(INTV.LtoFlash.Model.Commands.ProtocolCommandId command, string errorMessage, System.Exception exception) { var handled = false; var title = string.Empty; var messageFormat = string.Empty; switch (command) { case Model.Commands.ProtocolCommandId.FirmwareEraseSecondary: handled = true; title = Resources.Strings.RestoreFirmwareCommand_Failed_Title; messageFormat = Resources.Strings.RestoreFirmwareCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareProgramSecondary: handled = true; title = Resources.Strings.Firmware_UpdateFirmwareCommand_Failed_Title; messageFormat = Resources.Strings.Firmware_UpdateFirmwareCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareGetRevisions: handled = true; title = Resources.Strings.GetFirmwareRevisionsCommand_Failed_Title; messageFormat = Resources.Strings.GetFirmwareRevisionsCommand_Failed_Message_Format; break; case Model.Commands.ProtocolCommandId.FirmwareValidateImageInRam: handled = true; title = Resources.Strings.ProtocolCommandId_FirmwareValidateImageInRam_Title; messageFormat = Resources.Strings.ProtocolCommandId_FirmwareValidateImageInRam_Failed; break; } if (handled) { var message = string.Format(System.Globalization.CultureInfo.CurrentCulture, messageFormat, errorMessage); OSMessageBox.Show(message, title); } return(handled); }
/// <summary> /// Initializes a new instance of of the UnsupportedCommandException class. /// </summary> /// <param name="commandId">The unsupported command.</param> public UnsupportedCommandException(INTV.LtoFlash.Model.Commands.ProtocolCommandId commandId) : base(string.Format(Resources.Strings.ProtocolCommand_UnexpectedCommandError_Format, commandId)) { CommandId = commandId; }