本文整理汇总了C#中ErrorCode类的典型用法代码示例。如果您正苦于以下问题:C# ErrorCode类的具体用法?C# ErrorCode怎么用?C# ErrorCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ErrorCode类属于命名空间,在下文中一共展示了ErrorCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AjaxRedirect
public virtual ActionResult AjaxRedirect(ErrorCode result, string successUrl, string failUrl = "")
{
AjaxStatusCode status = result == ErrorCode.NoError ? AjaxStatusCode.Success : AjaxStatusCode.Error;
string targetAction = result == ErrorCode.NoError ? successUrl : failUrl;
string message = EnumHelper.GetDescription(result);
return MyAjaxHelper.RedirectAjax(status, message, null, targetAction);
}
示例2: CheckForStaticClass
// Generate an error if CType is static.
public bool CheckForStaticClass(Symbol symCtx, CType CType, ErrorCode err)
{
if (!CType.isStaticClass())
return false;
ReportStaticClassError(symCtx, CType, err);
return true;
}
示例3: CheckError
public static ErrorCode CheckError (ErrorCode error)
{
if (IsError (error))
throw ErrorException (error);
return error;
}
示例4: GetSeverity
internal static DiagnosticSeverity GetSeverity(ErrorCode code)
{
if (code == ErrorCode.Void)
{
return InternalDiagnosticSeverity.Void;
}
else if (code == ErrorCode.Unknown)
{
return InternalDiagnosticSeverity.Unknown;
}
else if (IsWarning(code))
{
return DiagnosticSeverity.Warning;
}
else if (IsInfo(code))
{
return DiagnosticSeverity.Info;
}
else if (IsHidden(code))
{
return DiagnosticSeverity.Hidden;
}
else
{
return DiagnosticSeverity.Error;
}
}
示例5: UsbError
internal UsbError(ErrorCode errorCode, int win32ErrorNumber, string win32ErrorString, string description, object sender)
{
mSender = sender;
string senderText = String.Empty;
if ((mSender is UsbEndpointBase)|| (mSender is UsbTransfer))
{
UsbEndpointBase ep;
if (mSender is UsbTransfer)
ep = ((UsbTransfer)mSender).EndpointBase;
else
ep = mSender as UsbEndpointBase;
if (ep.mEpNum != 0)
{
senderText = senderText+=string.Format(" Ep 0x{0:X2} ", ep.mEpNum);
}
}
else if (mSender is Type)
{
Type t = mSender as Type;
senderText = senderText += string.Format(" {0} ", t.Name);
}
mErrorCode = errorCode;
mWin32ErrorNumber = win32ErrorNumber;
mWin32ErrorString = win32ErrorString;
mDescription = description + senderText;
}
示例6: ThrowOnFailure
internal static void ThrowOnFailure(ErrorCode errorCode)
{
if (errorCode >= 0)
return;
switch (errorCode)
{
case ErrorCode.OutOfHostMemory:
throw new OutOfMemoryException("Could not allocate OpenCL resources on the host.");
case ErrorCode.OutOfResources:
throw new OutOfMemoryException("Could not allocate OpenCL resources on the device.");
case ErrorCode.DevicePartitionFailed:
throw new InvalidOperationException("The device could not be further partitioned.");
case ErrorCode.InvalidDevicePartitionCount:
throw new InvalidOperationException("Invalid device partition size.");
case ErrorCode.InvalidCommandQueue:
throw new ArgumentException("Invalid command queue.");
case ErrorCode.InvalidEventWaitList:
throw new ArgumentException("The event wait list contained an invalid event.");
case ErrorCode.InvalidDevice:
throw new ArgumentException("Invalid device.");
case ErrorCode.InvalidValue:
throw new ArgumentException("Invalid value.");
default:
throw new Exception(string.Format("Unknown error code: {0}", errorCode));
}
}
示例7: FormatMessage
private static string FormatMessage(ErrorCode errorCode, string info)
{
switch (errorCode)
{
case ErrorCode.TooManyWarnings:
info = string.Format("There are more than {0} warnings", CodeGeneratorWarnings.MaximumWarningCount);
break;
case ErrorCode.InvalidIncludeTemplateFormat:
info = "Include placeholders must have the following format: $NAME$(filename)";
break;
case ErrorCode.InvalidIncludeTemplateFormatOpeningBracket:
info = string.Format("{0} is missing \"(\"", info);
break;
case ErrorCode.InvalidIncludeTemplateFormatClosingBracket:
info = string.Format("{0} is missing \")\"", info);
break;
}
if (info == null || info == string.Empty)
info = "No Info"; // should not occur
return string.Format("OBLXE{0:d4}: {1}: {2}", (int)errorCode, errorCode.ToString(), info);
}
示例8: TransformToOptionObject_CustomOptionObjectWithProperties_PropertyValuesAreEqual
public void TransformToOptionObject_CustomOptionObjectWithProperties_PropertyValuesAreEqual(ErrorCode errorCode)
{
var transform = InitTransform();
var customOptionObject = MockBasicCustomOptionObject();
customOptionObject.ErrorCode = errorCode;
var result = transform.TransformToOptionObject(customOptionObject);
var expected = new object[]
{
customOptionObject.EntityID,
customOptionObject.EpisodeNumber,
(double)customOptionObject.ErrorCode,
customOptionObject.ErrorMesg,
customOptionObject.Facility,
customOptionObject.OptionId,
customOptionObject.OptionStaffId,
customOptionObject.OptionUserId,
customOptionObject.SystemCode
};
var actual = new object[]
{
result.EntityID,
result.EpisodeNumber,
result.ErrorCode,
result.ErrorMesg,
result.Facility,
result.OptionId,
result.OptionStaffId,
result.OptionUserId,
result.SystemCode
};
CollectionAssert.AreEqual(expected, actual);
}
示例9: JabberException
public JabberException(ErrorCode errorCode)
: base()
{
StreamError = false;
CloseStream = false;
this.ErrorCode = errorCode;
}
示例10: Add
/// <summary>
/// Add a diagnostic to the bag.
/// </summary>
/// <param name="diagnostics"></param>
/// <param name="code"></param>
/// <param name="location"></param>
/// <param name="args"></param>
/// <returns></returns>
internal static CSDiagnosticInfo Add(this DiagnosticBag diagnostics, ErrorCode code, Location location, params object[] args)
{
var info = new CSDiagnosticInfo(code, args);
var diag = new CSDiagnostic(info, location);
diagnostics.Add(diag);
return info;
}
示例11: GetResponseMessage
public GetResponseMessage(int requestId, VersionCode version, OctetString community, ErrorCode error, int index, IList<Variable> variables)
{
if (variables == null)
{
throw new ArgumentNullException("variables");
}
if (community == null)
{
throw new ArgumentNullException("community");
}
if (version == VersionCode.V3)
{
throw new ArgumentException("Please use overload constructor for v3", "version");
}
Version = version;
Header = Header.Empty;
Parameters = new SecurityParameters(null, null, null, community, null, null);
GetResponsePdu pdu = new GetResponsePdu(
requestId,
error,
index,
variables);
Scope = new Scope(pdu);
Privacy = DefaultPrivacyProvider.DefaultPair;
_bytes = SnmpMessageExtension.PackMessage(Version, Header, Parameters, Scope, Privacy).ToBytes();
}
示例12: BaseException
public BaseException(ErrorCode errorNumber, string errorMsg, Exception innerError)
: base(errorMsg, innerError)
{
this.mTime = DateTime.Now;
this.errorNumber = errorNumber;
this.errorMsg = errorMsg + (innerError == null ? string.Empty : ": " + innerError.Message);
}
示例13: ProtocolException
/// <summary>
/// Initializes a new instance of the <see cref="ProtocolException"/> class.
/// </summary>
/// <param name="protocolVersion">The CQL binary protocol version in use.</param>
/// <param name="code">The code.</param>
/// <param name="message">The message.</param>
/// <param name="tracingId">The tracing identifier.</param>
internal ProtocolException(byte protocolVersion, ErrorCode code, string message, Guid? tracingId)
: base(code + ": " + message)
{
Code = code;
ProtocolVersion = protocolVersion;
TracingId = tracingId;
}
示例14: Status
public Status(MessageHeader header, ErrorSeverity errorSeverity, ErrorCode errorCode, string description)
: base(header, CommandType.Status)
{
Severity = errorSeverity;
Code = errorCode;
Description = description;
}
示例15: ReportError
public override void ReportError(ErrorCode errorCode, string message, string file, int lineNumber)
{
if(errorCode == ErrorCode.Assertion || errorCode == ErrorCode.InternalError || errorCode == ErrorCode.OutOfMemory )
ActiveLogger.LogMessage("PhysX: " + message, LogLevel.FatalError);
else
ActiveLogger.LogMessage("PhysX: " + message, LogLevel.RecoverableError);
}