private async Task Command_CommandError(CommandsNextExtension sender, CommandErrorEventArgs e) { await ErrorHandlers.Process(e, BotEventId); //default logging to console below: sender.Client.Logger.LogWarning(BotEventId, $"{e.Command.Name} Command Error: {e.Exception.GetType()}: {e.Exception.Message ?? "<no message>"} by [{e.Context.User}] in [{e.Context.Channel.Name} ({e.Context.Channel.Id})] "); //changes from time to time }
private void HandleException(Exception excp) { // ignore secondary exceptions if (_state == AsyncClassState.Faulted) { Logger.LogDebug("HandleException: Ignoring due to Faulted state: {0}", excp); return; } // notify asynchronous delegates if (AsyncErrorHandlers != null) { _userDispatcher.DispatchCall(new AsyncErrorParams(excp, _context), AsyncErrorCallback); } // handle the exception try { _state = AsyncClassState.Faulted; OnAsyncException(excp); ErrorHandlers?.Invoke(excp, _context); } catch { // we tried our best - ignore Logger.Log(excp); } }
public override async Task Transition() { try { // Note: this step is necessary because anonymous types from outside assemblies are not referenced // as objects, so their properties are not accessible. // See: https://stackoverflow.com/questions/9416095/dynamic-does-not-contain-a-definition-for-a-property-from-a-project-reference Input = JsonConvert.DeserializeObject <TInput>(JsonConvert.SerializeObject(Input)); Request = Mapping.Invoke(Input); Response = await(Task <TResponse>) method.Invoke(Client, new object[] { Request, CancellationToken.None }); // by default we set the response as the output Output = Response; } catch (Exception exception) { if (ErrorHandlers.ContainsKey(exception.GetType())) { var execptionType = exception.GetType(); var handler = ErrorHandlers[execptionType]; if (handler.FallbackState is TransitionalState transitionalFallbackState) { // TODO: apply Result Path filter. // Find the method to invoke next, then transition to it. transitionalFallbackState.Input = Input; await transitionalFallbackState.Transition(); } else { return; } } throw; } // Apply response mappings // Set the next states intput to this ones output. if (NextState != null) { NextState.Input = Output; } Console.WriteLine($"State: {Name}"); Console.WriteLine(); if (NextState is TransitionalState transitionalState) { await transitionalState.Transition(); } }
public ActionResult Dashboard(ErrorHandlers errorHandler, string createmanpower = "", string Filter = "") { ViewBag.createmanpower = createmanpower; ViewBag.ManpowerRequestActive = "active"; ManpowerDashboardViewModel i = new ManpowerDashboardViewModel() { Filter = Filter, ErrorHandlers = errorHandler }; return(View(i)); }
public ActionResult dashboard(ErrorHandlers ErrorHandlers, string company = "") { ViewBag.SettingActive = "active"; ViewBag.company = company; CompanyViewModel model = new CompanyViewModel() { ErrorHandler = ErrorHandlers }; return(View(model)); }
public async Task <ActionResult> ImportManpowerRequest() { ImportManpower import = new ImportManpower(); var am = db.sp_get_account_manager_id(User.Identity.GetUserId()).FirstOrDefault(); var files = Request.Files[0]; var filename = Tools.RandomFileName(files); string path = Server.MapPath("~/excel/" + filename); files.SaveAs(path); ErrorHandlers errorHandlers = await import.ImportManpowerRequest(path, User.Identity.GetUserId(), generateurl(am.account_manager_1), generateurl(am.account_manager_2)); return(RedirectToAction("dashboard", "manpower", errorHandlers)); }
public void Handle(T parameters) { try { this.handler.Handle(parameters); } catch (Exception ex) { //****************************** //Code for logging will go here. //****************************** ErrorHandlers.ThrowServerErrorException(ex); throw; } }
/// <summary>Advances this request by checking in on it's progress.</summary> public void Update(float deltaTime) { if (WWWRequest == null) { // Not setup yet. return; } if (LoadingEnumerator == null) { // Let's go! LoadingEnumerator = Loader(); // Advance the first time: LoadingEnumerator.MoveNext(); } Duration += deltaTime; if (Duration >= Timeout_) { // Timeout! Package.TimedOut(); // Done: Remove(); return; } if (WWWRequest.isDone) { if (Package.readyState_ < 2) { // Load the headers: HandleHeaders(); } if (Errored) { // Figure out a suitable error code: Package.statusCode = ErrorHandlers.GetUnityErrorCode(Error); } if (!WWWRequest.isDone) { // Yes, this is actually possible! Quit and go around again: return; } // Received: #if UNITY_2017_1_OR_NEWER byte[] bytes = WWWRequest.downloadHandler.data; #else byte[] bytes = WWWRequest.bytes; #endif Package.ReceivedData(bytes, 0, bytes.Length); // Pop it from the update queue: Remove(); } else if (Progress != 0f) { if (Package.readyState_ < 2) { // Got headers yet? HandleHeaders(); #if !MOBILE && !UNITY_WEBGL && !UNITY_TVOS } else if (Package.readyState_ == 2 && Movie != null && Movie.isReadyToPlay) { // Downloaded it far enough to try playing it - let the package know: Package.ReceivedMovieTexture(Movie); #endif } } }
public ErrorHandlers ImportCompany(DataTable dt) { ErrorHandlers ErrorHandler = null; List <CompanyViewModel> list = new List <CompanyViewModel>(); string Message = "Imported file is empty"; string ClassName = "alert alert-danger"; bool error = true; int row = 1; foreach (DataRow dr in dt.Rows) { CompanyViewModel model = new CompanyViewModel() { company_name = Tools.ToTitleCase(dr[0].ToString()), branch = Tools.ToTitleCase(dr[1].ToString()), brand = Tools.ToTitleCase(dr[2].ToString()), officeaddress = Tools.ToTitleCase(dr[3].ToString()), industry = dr[4].ToString() }; if (model.company_name == "") { Message = "Client Name* field is required at row " + row; ClassName = "alert alert-danger"; error = true; break; } if (model.branch == "") { Message = "Branch* field is required at row " + row; ClassName = "alert alert-danger"; error = true; break; } if (model.officeaddress == "") { Message = "Office Address* field is required at row " + row; ClassName = "alert alert-danger"; error = true; break; } if (model.industry == "") { Message = "Industry* field is required at row " + row; ClassName = "alert alert-danger"; error = true; break; } var IndustryName = Manpower.GetIndustryID(model.industry); if (IndustryName == "") { Message = "Invalid entry on the Industry field at row " + row; ClassName = "alert alert-danger"; error = true; break; } else { model.industry = IndustryName; } row++; list.Add(model); } if (error == false && list.Count() > 0) { foreach (var i in list) { db.sp_add_companies(i.company_name, i.branch, i.branch, i.officeaddress, i.industry); } Message = "Successfully Import Client Information"; ClassName = "alert alert-success"; } ErrorHandler = new ErrorHandlers() { Message = Message, _Class = ClassName }; //Manpower.GetIndustryID() return(ErrorHandler); }