internal BaseError(IDocumentError innerError, Exception internalException, DocumentErrorKind kind, DocumentErrorSeverity severity, ErrorResourceKey errKey, Span textSpan, IEnumerable <string> sinkTypeErrors, params object[] args) { Contracts.AssertValueOrNull(innerError); Contracts.AssertValueOrNull(args); Contracts.AssertValueOrNull(internalException); Contracts.AssertValueOrNull(textSpan); Contracts.AssertValueOrNull(sinkTypeErrors); InnerError = innerError; ErrorKind = kind; Entity = string.Empty; PropertyName = string.Empty; Parent = string.Empty; Severity = severity; InternalException = internalException; TextSpan = textSpan; SinkTypeErrors = sinkTypeErrors; MessageKey = errKey.Key; MessageArgs = args; // We expect errKey to be the key for an error resource object within string resources. // We fall back to using a basic content string within string resources, for errors // that haven't yet been converted to an ErrorResource in the Resources.pares file. ErrorResource errorResource; string shortMessage; string longMessage; if (!StringResources.TryGetErrorResource(errKey, out errorResource)) { errorResource = null; shortMessage = StringResources.Get(errKey.Key); longMessage = null; } else { shortMessage = errorResource.GetSingleValue(ErrorResource.ShortMessageTag); Contracts.AssertValue(shortMessage); longMessage = errorResource.GetSingleValue(ErrorResource.LongMessageTag); } ShortMessage = FormatMessage(shortMessage, args); LongMessage = FormatMessage(longMessage, args); HowToFixMessages = errorResource?.GetValues(ErrorResource.HowToFixTag) ?? GetHowToFix(errKey.Key); WhyToFixMessage = errorResource?.GetSingleValue(ErrorResource.WhyToFixTag) ?? string.Empty; Links = errorResource?.HelpLinks; }
internal BaseError(IDocumentError innerError, Exception internalException, DocumentErrorKind kind, DocumentErrorSeverity severity, ErrorResourceKey errKey, params object[] args) : this(innerError, internalException, kind, severity, errKey, textSpan : null, sinkTypeErrors : null, args : args) { }