/// <summary> /// Finds object by name. /// </summary> /// <typeparam name="T">Type of object (TexturedObject, GameObject etc.)</typeparam> public static T Get <T>(string name) where T : RenderableObject { lock (All) foreach (RenderableObject o in All) { if (o.Name == name && o is T) { return((T)o); } } Exception ex = new ObjectException("Could not find object \"" + name + "\" with type \"" + typeof(T).FullName + "\""); Log.Exception(ex); throw ex; }
/// <summary> /// Finds object by name /// </summary> public static RenderableObject Get(string name) { lock (All) foreach (RenderableObject o in All) { if (o.Name == name) { return(o); } } Exception ex = new ObjectException("Could not find object \"" + name + "\""); Log.Exception(ex); throw ex; }
private RenderableObject findByID(uint id) { lock (All) foreach (RenderableObject o in All) { if (o.ID == id) { return(o); } } Exception ex = new ObjectException("Could not find object with ID " + id); Log.Exception(ex); throw ex; }
protected override async ValueTask <ActionEvent> ExecuteInternalAsync(CancellationToken token) { if (token.IsCancellationRequested) { return(await NotifyCancelEventAsync().DonotCapture()); } HttpReq req = null; try { req = BuildRequest(); var response = await HttpService.ExecuteAsync(req, token).DonotCapture(); PreCheckResponse(response); var result = await HandleResponse(response).DonotCapture(); return(result); } catch (TaskCanceledException) { return(await NotifyCancelEventAsync().DonotCapture()); } catch (Exception ex) { if (Logger.IsEnabled(LogLevel.Trace) && req != null) { // 此处用于生成请求信息,然后用fiddler等工具测试 var url = req.GetUrl(); var header = req.GetRequestHeader(HttpService.GetCookies(req.Uri)); Logger.LogTrace(ex.ToString()); Logger.LogTrace(url); Logger.LogTrace(header); } return(await HandleExceptionAsync(ObjectException.Create(req, ex.Message, ex)) .DonotCapture()); } finally { ++ExcuteTimes; } }
protected ValueTask <ActionEvent> NotifyObjectErrorAsync <T>(T obj, string msg = null, Exception innerException = null) => NotifyErrorAsync(ObjectException.Create(obj, msg, innerException));
public HappenedException(ObjectException exception) { Type = exception.GetType().ToString(); Description = exception.Message; }