/// <summary> /// Show a notification with "Error: " prefixed to the message. /// </summary> /// <param name="errorMessage">The error message template.</param> /// <param name="blink">Should the notification blink 3 times?</param> /// <param name="saveToBrief">Should the notification be logged to the brief (PAUSE menu > INFO > Notifications)?</param> /// <param name="placeholderValue">An optional string that will be replaced inside the error message template.</param> public void Error(CommonErrors errorMessage, bool blink = false, bool saveToBrief = true, string placeholderValue = null) { string message = ErrorMessage.Get(errorMessage, placeholderValue); Error(message, blink, saveToBrief); }
/// <summary> /// Show a notification with "Alert: " prefixed to the message. /// </summary> /// <param name="errorMessage">The error message template.</param> /// <param name="blink">Should the notification blink 3 times?</param> /// <param name="saveToBrief">Should the notification be logged to the brief (PAUSE menu > INFO > Notifications)?</param> /// <param name="placeholderValue">An optional string that will be replaced inside the error message template.</param> public static void Alert(CommonErrors errorMessage, bool blink = true, bool saveToBrief = true, string placeholderValue = null) { string message = ErrorMessage.Get(errorMessage, placeholderValue); Alert(message, blink, saveToBrief); }
/// <summary> /// Returns the formatted error message for the specified error type. /// </summary> /// <param name="errorType">The error type.</param> /// <param name="placeholderValue">An optional string that will be replaced inside the error message (if applicable).</param> /// <returns>The error message.</returns> public static string Get(CommonErrors errorType, string placeholderValue = null) { string outputMessage = ""; string placeholder = placeholderValue != null ? " " + placeholderValue : ""; switch (errorType) { case CommonErrors.NeedToBeTheDriver: outputMessage = "You need to be the driver of this vehicle."; break; case CommonErrors.NoVehicle: outputMessage = $"You need to be inside a vehicle{placeholder}."; break; case CommonErrors.NotAllowed: outputMessage = $"You are not allowed to{placeholder}, sorry."; break; case CommonErrors.InvalidModel: outputMessage = $"This model~r~{placeholder} ~s~could not be found, are you sure it's valid?"; break; case CommonErrors.InvalidInput: outputMessage = $"The input~r~{placeholder} ~s~is invalid or you cancelled the action, please try again."; break; case CommonErrors.InvalidSaveName: outputMessage = $"Saving failed because the provided save name~r~{placeholder} ~s~is invalid."; break; case CommonErrors.SaveNameAlreadyExists: outputMessage = $"Saving failed because the provided save name~r~{placeholder} ~s~already exists."; break; case CommonErrors.CouldNotLoadSave: outputMessage = $"Loading of~r~{placeholder} ~s~failed! Is the saves file corrupt?"; break; case CommonErrors.CouldNotLoad: outputMessage = $"Could not load~r~{placeholder}~s~, sorry!"; break; case CommonErrors.PedNotFound: outputMessage = $"The specified ped could not be found.{placeholder}"; break; case CommonErrors.PlayerNotFound: outputMessage = $"The specified player could not be found.{placeholder}"; break; case CommonErrors.WalkingStyleNotForMale: outputMessage = $"This walking style is not available for male peds.{placeholder}"; break; case CommonErrors.WalkingStyleNotForFemale: outputMessage = $"This walking style is not available for female peds.{placeholder}"; break; case CommonErrors.UnknownError: default: outputMessage = $"An unknown error occurred, sorry!{placeholder}"; break; } return(outputMessage); }
public IDispatchAccessException(string message, object target, string memberNameIfSpecified, int?dispIdIfKnown, CommonErrors errorType, Exception innerException = null) : base(message, innerException) { if (target == null) { throw new ArgumentNullException("target"); } if (string.IsNullOrWhiteSpace(memberNameIfSpecified) && (dispIdIfKnown == null)) { throw new ArgumentException("At least one of memberNameIfSpecified and dispIdIfKnown must be specified"); } if (!Enum.IsDefined(typeof(CommonErrors), errorType)) { ErrorType = errorType; } Target = target; MemberNameIfSpecified = memberNameIfSpecified; DispIdIfKnown = dispIdIfKnown; ErrorType = errorType; }