本文整理汇总了C#中System.Exception.ToMessageWithType方法的典型用法代码示例。如果您正苦于以下问题:C# Exception.ToMessageWithType方法的具体用法?C# Exception.ToMessageWithType怎么用?C# Exception.ToMessageWithType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Exception
的用法示例。
在下文中一共展示了Exception.ToMessageWithType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Wrap
public static MVCActionException Wrap(string controller, string action, Exception src)
{
if (src==null) throw new WaveException(StringConsts.ARGUMENT_ERROR+typeof(MVCActionException).Name+"Wrap(src=null)");
var trace = src.StackTrace;
return new MVCActionException(controller,
action,
"Controller action: '{0}'.'{1}'. Exception: {2} Trace: \r\n {3}".Args(controller, action, src.ToMessageWithType(), trace),
src);
}
示例2: RowToRecordInitJSON
/// <summary>
/// Generates JSON object suitable for passing into WV.RecordModel.Record(...) constructor on the client.
/// Pass target to select attributes targeted to ANY target or to the specified one, for example
/// may get attributes for client data entry screen that sees field metadata differently, in which case target will reflect the name
/// of the screen
/// </summary>
public static JSONDataMap RowToRecordInitJSON(Row row, Exception validationError, string recID = null, string target = null, string isoLang = null)
{
var result = new JSONDataMap();
if (row==null) return result;
if (recID.IsNullOrWhiteSpace()) recID = Guid.NewGuid().ToString();
result["OK"] = true;
result["ID"] = recID;
if (isoLang.IsNotNullOrWhiteSpace())
result["ISOLang"] = isoLang;
//20140914 DKh
if (row is FormModel)
{
result[FormModel.JSON_MODE_PROPERTY] = ((FormModel)row).FormMode;
result[FormModel.JSON_CSRF_PROPERTY] = ((FormModel)row).CSRFToken;
}
var fields = new JSONDataArray();
result["fields"] = fields;
var schemaName = row.Schema.Name;
if (row.Schema.TypedRowType!=null) schemaName = row.Schema.TypedRowType.FullName;
foreach(var fdef in row.Schema.FieldDefs.Where(fd=>!fd.NonUI))
{
var fld = new JSONDataMap();
fields.Add(fld);
fld["def"] = fieldDefToJSON(schemaName, fdef, target);
fld["val"] = row.GetFieldValue(fdef);
var ferr = validationError as CRUDFieldValidationException;
//field level exception
if (ferr!= null && ferr.FieldName==fdef.Name)
{
fld["error"] = ferr.ToMessageWithType();
fld["errorText"] = localizeString(schemaName, "errorText", ferr.ClientMessage);
}
}
//record level
if (validationError!=null && !(validationError is CRUDFieldValidationException))
{
result["error"] = validationError.ToMessageWithType();
result["errorText"] = localizeString(schemaName, "errorText", validationError.Message);
}
return result;
}
示例3: logError
private void logError(string from, Exception error)
{
App.Log.Write(
new Message
{
Type = MessageType.CatastrophicError,
Topic = StringConsts.SVCAPPLICATION_TOPIC,
From = from,
Exception = error,
Text = error.ToMessageWithType()
});
}
示例4: HandleException
/// <summary>
/// Handles processing exception by calling ErrorFilter.HandleException(work, error).
/// All parameters except ERROR can be null - which indicates error that happened during WorkContext dispose
/// </summary>
public virtual void HandleException(WorkContext work, WorkFilter filter, WorkHandler handler, Exception error)
{
try
{
if (m_InstrumentationEnabled) Interlocked.Increment(ref m_Stat_ServerHandleException);
//work may be null (when WorkContext is already disposed)
if (work!=null)
ErrorFilter.HandleException(work, error, m_ErrorShowDumpMatches, m_ErrorLogMatches);
else
Log(MessageType.Error,
StringConsts.SERVER_DEFAULT_ERROR_WC_NULL_ERROR + error.ToMessageWithType(),
"HandleException()",
error);
}
catch(Exception error2)
{
if (m_LogHandleExceptionErrors)
try
{
Log(MessageType.Error,
StringConsts.SERVER_DEFAULT_ERROR_HANDLER_ERROR + error2.ToMessageWithType(),
"HandleException.catch()",
error2,
pars: new
{
OriginalError = error.ToMessageWithType()
}.ToJSON()
);
}
catch{}
}
}
示例5: HandleException
/// <summary>
/// Handles the exception by responding appropriately with error page with conditional level of details and logging
/// </summary>
public static void HandleException(WorkContext work,
Exception error,
OrderedRegistry<WorkMatch> showDumpMatches,
OrderedRegistry<WorkMatch> logMatches,
string securityRedirectURL = null,
Type customPageType = null
)
{
if (work==null || error==null) return;
var showDump = showDumpMatches != null ?
showDumpMatches.OrderedValues.Any(m => m.Make(work)!=null) : false;
if (work.Response.Buffered)
work.Response.CancelBuffered();
var json = false;
if (work.Request!=null && work.Request.AcceptTypes!=null)//if needed for some edge HttpListener cases when Request or Request.AcceptTypes are null
json = work.Request.AcceptTypes.Any(at=>at.EqualsIgnoreCase(ContentType.JSON));
var actual = error;
if (actual is FilterPipelineException)
actual = ((FilterPipelineException)actual).RootException;
if (json)
{
work.Response.ContentType = ContentType.JSON;
work.Response.WriteJSON(error.ToClientResponseJSONMap(showDump));
}
else
{
if (securityRedirectURL.IsNotNullOrWhiteSpace() && (actual is NFX.Security.AuthorizationException || actual.InnerException is NFX.Security.AuthorizationException))
work.Response.RedirectAndAbort(securityRedirectURL);
else
{
WaveTemplate errorPage = null;
if (customPageType!=null)
try
{
errorPage = Activator.CreateInstance(customPageType) as WaveTemplate;
if (errorPage==null) throw new WaveException("not WaveTemplate");
}
catch(Exception actErr)
{
work.Log(Log.MessageType.Error,
StringConsts.ERROR_PAGE_TEMPLATE_TYPE_ERROR.Args(customPageType.FullName, actErr.ToMessageWithType()),
typeof(ErrorFilter).FullName+".ctor(customPageType)",
actErr);
}
if (errorPage==null)
errorPage = new ErrorPage(work, error, showDump);
errorPage.Render(work, error);
}
}
if (actual is HTTPStatusException)
{
var se = (HTTPStatusException)actual;
work.Response.StatusCode = se.StatusCode;
work.Response.StatusDescription = se.StatusDescription;
}
if (logMatches!=null && logMatches.Count>0)
{
JSONDataMap matched = null;
foreach(var match in logMatches.OrderedValues)
{
matched = match.Make(work);
if (matched!=null) break;
}
if (matched!=null)
work.Log(Log.MessageType.Error, error.ToMessageWithType(), typeof(ErrorFilter).FullName, pars: matched.ToJSON(JSONWritingOptions.CompactASCII));
}
}
示例6: log
private void log(MessageType type, string from, string text, Exception error,
[CallerFilePath] string file = null,
[CallerLineNumber]int line = 0,
object pars = null)
{
App.Log.Write(
new Message(pars, file, line)
{
Type = type,
Topic = CoreConsts.ERLANG_TOPIC,
From = error == null ? "{0}.{1}".Args(GetType().Name, from) : error.ToMessageWithType(),
Text = text,
Exception = error
}
);
}
示例7: WrapActionResultError
public static MVCActionException WrapActionResultError(string controller, string action, object result, Exception src)
{
if (src==null) throw new WaveException(StringConsts.ARGUMENT_ERROR+typeof(MVCActionException).Name+"Wrap(src=null)");
var trace = src.StackTrace;
return new MVCActionException(controller,
action,
"Controller action result processing: '{0}'.'{1}' -> {2}. Exception: {3} Trace: \r\n {4}".Args(controller,
action,
result==null ? "<null>" : result.GetType().FullName,
src.ToMessageWithType(),
trace),
src);
}
示例8: RowToRecordInitJSON
/// <summary>
/// Generates JSON object suitable for passing into WV.RecordModel.Record(...) constructor on the client.
/// Pass target to select attributes targeted to ANY target or to the specified one, for example
/// may get attributes for client data entry screen that sees field metadata differently, in which case target will reflect the name
/// of the screen
/// </summary>
public virtual JSONDataMap RowToRecordInitJSON(Row row,
Exception validationError,
string recID = null,
string target = null,
string isoLang = null,
ModelFieldValueListLookupFunc valueListLookup = null)
{
var result = new JSONDataMap();
if (row==null) return result;
if (recID.IsNullOrWhiteSpace()) recID = Guid.NewGuid().ToString();
result["OK"] = true;
result["ID"] = recID;
if (isoLang.IsNotNullOrWhiteSpace())
result["ISOLang"] = isoLang;
//20140914 DKh
var form = row as FormModel;
if (form != null)
{
result[FormModel.JSON_MODE_PROPERTY] = form.FormMode;
result[FormModel.JSON_CSRF_PROPERTY] = form.CSRFToken;
//20160123 DKh
if (form.HasRoundtripBag)
result[FormModel.JSON_ROUNDTRIP_PROPERTY] = form.RoundtripBag.ToJSON(JSONWritingOptions.CompactASCII);
}
var fields = new JSONDataArray();
result["fields"] = fields;
var schemaName = row.Schema.Name;
if (row.Schema.TypedRowType!=null) schemaName = row.Schema.TypedRowType.FullName;
foreach(var sfdef in row.Schema.FieldDefs.Where(fd=>!fd.NonUI))
{
var fdef = row.GetClientFieldDef(this, sfdef, target, isoLang);
if (fdef==null || fdef.NonUI) continue;
var fld = new JSONDataMap();
fields.Add(fld);
fld["def"] = FieldDefToJSON(row, schemaName, fdef, target, isoLang, valueListLookup);
var val = row.GetClientFieldValue(this, sfdef, target, isoLang);
if (val is GDID && ((GDID)val).IsZero) val = null;
fld["val"] = val;
var ferr = validationError as CRUDFieldValidationException;
//field level exception
if (ferr!= null && ferr.FieldName==fdef.Name)
{
fld["error"] = ferr.ToMessageWithType();
fld["errorText"] = OnLocalizeString(schemaName, "errorText", ferr.ClientMessage, isoLang);
}
}
//record level
if (validationError!=null && !(validationError is CRUDFieldValidationException))
{
result["error"] = validationError.ToMessageWithType();
result["errorText"] = OnLocalizeString(schemaName, "errorText", validationError.Message, isoLang);
}
return result;
}
示例9: DoHandleError
protected override void DoHandleError(Exception error)
{
log(MessageType.Error, "DoHandleError()", "Job Fire() aborted with: "+error.ToMessageWithType(), error);
}