Class SimpleError
Base class for errors that obtain their messages from the Localization system.
public abstract class SimpleError : IError
- Inheritance
-
SimpleError
- Implements
- Inherited Members
Fields
_references
Any ObjectReferences to display to the user; the user will be able to click to jump to these objects.
public List<ObjectReference> _references
Field Value
Properties
DetailsKey
The key to use for the details section of the error display. By default, this is the TitleKey + :description
.
public virtual string DetailsKey { get; }
Property Value
DetailsSubst
String substitutions to insert into the details section of the error display. You can reference these with
e.g. {0}
.
public virtual string[] DetailsSubst { get; }
Property Value
- string[]
HintKey
The key to use for the hint section of the error display. By default, this is the TitleKey + :hint
.
This section should be used to provide a hint to the user about how to resolve the error.
public virtual string HintKey { get; }
Property Value
HintSubst
String substitutions to insert into the hint section of the error display. You can reference these with
e.g. {0}
.
public virtual string[] HintSubst { get; }
Property Value
- string[]
Localizer
The Localizer to use to look up strings.
public abstract Localizer Localizer { get; }
Property Value
References
Any ObjectReferences to display to the user; the user will be able to click to jump to these objects.
By default this just returns the _references
protected field.
public virtual ObjectReference[] References { get; }
Property Value
Severity
The severity of the error.
public abstract ErrorSeverity Severity { get; }
Property Value
TitleKey
The key to use for the title of the error. By default, all other keys are derived from this TitleKey.
public abstract string TitleKey { get; }
Property Value
TitleSubst
String substitutions to insert into the title of the error display. You can reference these with
e.g. {0}
.
public virtual string[] TitleSubst { get; }
Property Value
- string[]
Methods
AddReference(ObjectReference)
Adds a reference to a context object that might be helpful for tracking down the error.
public void AddReference(ObjectReference obj)
Parameters
obj
ObjectReference
CreateVisualElement(ErrorReport)
Creates a VisualElement used to display the error in the error report window.
public virtual VisualElement CreateVisualElement(ErrorReport report)
Parameters
report
ErrorReportThe report this error is in
Returns
- VisualElement
A VisualElement to display
FormatDetails()
Returns the formatted details message for the error.
public virtual string FormatDetails()
Returns
FormatHint()
Returns the formatted hint message for the error.
public virtual string FormatHint()
Returns
FormatTitle()
Returns the formatted title of the error.
public virtual string FormatTitle()
Returns
SafeSubst(string, string[])
Substitutes placeholders like {0}, {1} in the raw string message
with the values in
subst
. Unlike String.Format, this will not throw an exception if the number of substitutions does not
match the number of placeholders.
protected static string SafeSubst(string message, string[] subst)
Parameters
Returns
SafeSubstByKey(string, string[])
Substitutes placeholders like {0}, {1} in the localized string referenced by key
with the values in
subst
. Unlike String.Format, this will not throw an exception if the number of substitutions does not
match the number of placeholders.
protected string SafeSubstByKey(string key, string[] subst)
Parameters
Returns
ToMessage()
Formats the error as a string, suitable for being dumped to the unity log.
public virtual string ToMessage()