public static int Main () { var ex = new ApplicationException (); try { TestRethrow (ex).Wait (); } catch (AggregateException e) { if (e.InnerException != ex) return 1; } if (counter != 3) return 2; var ex2 = new NotSupportedException (); try { TestRethrow (ex2).Wait (); } catch (AggregateException e) { if (e.InnerException != ex2) return 3; } if (counter != 9) return 4; Console.WriteLine ("ok"); return 0; }
public static int Main() { if (TestCapturedException (null).Result != 3) return 1; var ex = new ApplicationException (); if (TestCapturedException (ex).Result != 2) return 2; return 0; }
public void SaveContact(Contact contact) { if (contact.IsValid) { if (contact.ContactId == 0) { ContactDAL.InsertContact(contact); } else { ContactDAL.UpdateContact(contact); } } else { ApplicationException ex = new ApplicationException(contact.Error); ex.Data.Add("Contact", contact); throw ex; } }
public void can_reject_promise_and_trigger_multiple_error_handlers_in_order() { var promise = new Promise <int>(); var ex = new ApplicationException(); var completed = 0; promise.Catch(e => { Assert.Equal(ex, e); Assert.Equal(1, ++completed); }); promise.Catch(e => { Assert.Equal(ex, e); Assert.Equal(2, ++completed); }); promise.Reject(ex); Assert.Equal(2, completed); }
private T Execute <T>(IRestRequest request) where T : new() { if (request == null) { throw new ArgumentNullException("request"); } var client = new RestClient { BaseUrl = BaseUrl }; request.AddParameter("api_key", _apiKey, ParameterType.UrlSegment); var response = client.Execute <T>(request); if (response.ErrorException != null) { const string message = "Error retrieving response. Check inner details for more info."; var nexalogyException = new ApplicationException(message, response.ErrorException); throw nexalogyException; } return(response.Data); }
public bool Update(permisos entidad) { SqlCommand cmd = new SqlCommand(); bool respuesta = false; try { AbrirConexion(); cmd.Connection = Conexion; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DML_Permisos"; cmd.Parameters.AddWithValue("@Sentencia", "Update"); cmd.Parameters.AddWithValue("@IdPermiso", entidad.id_permiso); cmd.Parameters.AddWithValue("@nombre", entidad.nombre); cmd.Parameters.AddWithValue("@descripcion", entidad.descripcion); cmd.Parameters.AddWithValue("@url", entidad.url); cmd.Parameters.AddWithValue("@id_menu_principal", entidad.id_menu_principal); cmd.ExecuteNonQuery(); respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de conversión de tipos con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar permisos"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar permisos"; throw excepcion; } finally { CerrarConexion(); cmd = null; } return(respuesta); }
private static async Task <ApplicationUser> CreateDefaultUser(UserManager <ApplicationUser> um, ILogger <DbInitializer> logger, string email) { logger.LogInformation($"Create default user with email `{email}` for application"); var user = new ApplicationUser(email, "Adm", "Adm", new DateTime(1970, 1, 1), true); var ir = await um.CreateAsync(user); if (ir.Succeeded) { logger.LogDebug($"Created default user `{email}` successfully"); } else { var exception = new ApplicationException($"Default user `{email}` cannot be created"); logger.LogError(exception, GetIdentiryErrorsInCommaSeperatedList(ir)); throw exception; } var createdUser = await um.FindByEmailAsync(email); return(createdUser); }
protected override void OnCreate(Bundle bundle) { // Rollbar notifier configuartion RollbarHelper.ConfigureRollbarSingleton(); // Registers for global exception handling. RollbarHelper.RegisterForGlobalExceptionHandling(); AndroidEnvironment.UnhandledExceptionRaiser += (sender, args) => { var newExc = new ApplicationException("AndroidEnvironment_UnhandledExceptionRaiser", args.Exception); RollbarHelper.RollbarInstance.AsBlockingLogger(TimeSpan.FromSeconds(10)).Critical(newExc); }; TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new App(new AndroidInitializer())); }
public IRestResponse Execute(RestRequest request) { var client = new RestClient { BaseUrl = BaseUrl }; IRestResponse response = client.Execute(request); if (response.ErrorException != null) { const string message = "Error retrieving response. Check inner details for more info."; var twilioException = new ApplicationException(message, response.ErrorException); throw twilioException; } //Need to check for errors if (response.StatusCode != System.Net.HttpStatusCode.OK) { throw new System.Exception(); } return(response); }
public void Build_should_return_full_url() { _errorReportMarkDownBodyBuilder.Build(Arg.Any <Exception>(), Arg.Any <string>()).Returns(x => @"## Current behaviour ``` System.ApplicationException: Failed ---> System.ArgumentOutOfRangeException: Opps ---> System.DivideByZeroException: Boom! --- End of inner exception stack trace --- --- End of inner exception stack trace --- at NBug.Tests.Unit.Util.Mock.Method1() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 13 at NBug.Tests.Unit.Util.Mock.Method2() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 16 at NBug.Tests.Unit.Util.Mock.Method3() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 17 at NBug.Tests.Unit.Util.Mock.Method4() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 18 at NBug.Tests.Unit.Util.Mock.DoWork() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\Mock.cs:line 7 at NBug.Tests.Unit.Util.ErrorReportMarkDownBodyBuilderTests.Build_should_build_report_without_system_or_additional_info() in C:\Development\gitextensions\Externals\NBug\NBug.Tests\Unit\Util\ErrorReportMarkDownBodyBuilderTests.cs:line 36 ``` ## Additional information It happened when I was arguing with someone on the Internet. I was right and they were absolutely wrong! I win!But the app crashed! PLEASE HELP!!! ## Environment - Git Extensions 0.0.2.5232 - Build 23b6f51905006ccdde8701591df706284b4155dc - Git 2.19.0.windows.1 - Microsoft Windows NT 10.0.17134.0 - .NET Framework 4.7.3324.0 - DPI 144dpi (150% scaling) "); var ex = new ApplicationException("BAU-863 adding settings and organisations if they are not already exist in the set"); var url = _gitHubUrlBuilder.Build("http://localhost/issues/new", ex, null); Approvals.Verify(url); }
public void SetExceptionAndUnobservedEvent() { var notFromMainThread = false; using (var mre = new ManualResetEvent(false)) { var mainThreadId = Thread.CurrentThread.ManagedThreadId; TaskScheduler.UnobservedTaskException += (o, args) => { notFromMainThread = Thread.CurrentThread.ManagedThreadId != mainThreadId; args.SetObserved(); mre.Set(); }; var inner = new ApplicationException(); CreateFaultedTaskCompletionSource(inner); GC.Collect(); GC.WaitForPendingFinalizers(); Assert.IsTrue(mre.WaitOne(5000), "#1"); Assert.IsTrue(notFromMainThread, "#2"); } }
/// <summary> /// Reperimento dei sottoscrittori disponibili nel sistema /// </summary> /// <returns></returns> private Subscriber.Proxy.ChannelInfo[] GetSubscribers(string serviceUrl) { //if (!this.PingSubscriberServices(serviceUrl)) // throw new ApplicationException("Servizio sottoscrittore non raggiungibile"); try { // Caricamento dei sottoscrittori configurati e raggiungibili tramite l'url indicato using (Subscriber.Proxy.SubscriberWebService ws = SubscriberServiceFactory.Create(serviceUrl)) return(ws.GetChannelList()); } catch (System.Web.Services.Protocols.SoapException soapEx) { ApplicationException ex = DocsPaUtils.Exceptions.SoapExceptionParser.GetOriginalException(soapEx); throw ex; } catch (Exception ex) { throw new ApplicationException("Servizio sottoscrittore non raggiungibile"); } }
static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(); StackifyLib.Utils.StackifyAPILogger.LogEnabled = true; for (int i = 0; i < 1000; i++) { var ex = new ApplicationException("Test error"); Logger.QueueException(ex); Logger.Queue("DEBUG", "test " + i); //log.Info("test info " + i); //log.Info("object test" + i, new { First = 1, Second = 2, OK = true, DT = DateTime.UtcNow }); //log.Info(new { OjectOnly = true, DT = DateTime.UtcNow, Child = new { First = 1, Second = 2, OK = true, DT = DateTime.UtcNow } }); //log.Debug("test debug " + i); //log.Fatal("test fatal " + i); //log.Error("test error " + i); //log.Error("test error object" + i, ex); System.Threading.Thread.Sleep(2000); } Debug.WriteLine("Closing app..."); }
/// <summary> /// This is a task which challenges the payload attributes from client side character set encoding to target system character set encoding. /// Documentation: https://github.com/CommunityHiQ/Frends.Community.SecurityThreatDiagnostics /// Throws application exception if diagnostics find vulnerability from the payload challenge. /// </summary> public static SecurityThreatDiagnosticsResult ChallengeCharacterSetEncoding(string payload, Options options) { string data = null; { try { data = ChangeCharacterEncoding(payload, options); } catch (Exception exception) { StringBuilder argumentExceptions = new StringBuilder("Security Threat Diagnostics vulnerability report invalid character encoding:"); StringBuilder applicationExceptions = new StringBuilder("Security Threat Diagnostics deep scanned the following attack vectors: "); try { argumentExceptions.Append(exception.Message.ToString()).Append("\n"); applicationExceptions.Append("Contains illegal characters: ").Append(payload).Append("\n"); ApplicationException applicationException = new ApplicationException(argumentExceptions.ToString()); ArgumentException argumentException = new ArgumentException(applicationExceptions.ToString()); throw new ApplicationException(applicationException.ToString(), argumentException); } finally { if (applicationExceptions != null) { argumentExceptions.Clear(); applicationExceptions.Clear(); } } } SecurityThreatDiagnosticsResult securityThreatDiagnosticsResult = new SecurityThreatDiagnosticsResult(); securityThreatDiagnosticsResult.IsValid = true; //securityThreatDiagnosticsResult.Data.Add("data", data); return(securityThreatDiagnosticsResult); } }
public bool Update(detalle_politicas entidad) { SqlCommand cmd = new SqlCommand(); bool respuesta = false; try { AbrirConexion(); cmd.Connection = Conexion; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "DML_detalle_politicas"; cmd.Parameters.AddWithValue("@Sentencia", "Update"); cmd.Parameters.AddWithValue("@IdDetallePolitica", entidad.id_detalle_politica); cmd.Parameters.AddWithValue("@id_politica", entidad.id_politica); cmd.Parameters.AddWithValue("@id_prioridad", entidad.id_prioridad); cmd.Parameters.AddWithValue("@tiempo_min", entidad.tiempo_min); cmd.Parameters.AddWithValue("@tiempo_max", entidad.tiempo_max); cmd.ExecuteNonQuery(); respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de conversión de tipos con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar detalle_politicas"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insertar detalle_politicas"; throw excepcion; } finally { CerrarConexion(); cmd = null; } return(respuesta); }
/// <summary> /// Method is executed when the background process finishes and returns here /// because it was cancelled or is done processing. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void FileLoaderLoadResultEvent(object sender, LogFileLoader.ResultEvent e) { _fileLoader.LoadResultEvent -= FileLoaderLoadResultEvent; _fileLoader = null; ManageRepositoriesViewModel.IsLoading = false; if (e.InnerException != null) { var exp = new ApplicationException(e.Message, e.InnerException) { Source = "LoadFileLoader" }; exp.Data.Add("Process cancelled?", e.Cancel.ToString()); MessageBox.Show(string.Format("Exception : {0} \n {1}", exp, e.Error), Resources.GlobalHelper_ParseLogFile_Error_Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); LoadFinishedEvent(false); } else { LoadFinishedEvent(true); } }
public BaseApiModel.BaseApi Execute() { BaseApiModel.BaseApi BaseApi = new BaseApiModel.BaseApi(); IRestResponse <BaseApiModel.BaseApi> response = restClient.Execute <BaseApiModel.BaseApi>(restRequest); if (response.ErrorException != null) { string message = "Error retrieving response. Check inner details for more info."; var exception = new ApplicationException(message, response.ErrorException); BaseApi.description = message + exception; BaseApi.isSuccess = false; } else { BaseApi = response.Data; } return(BaseApi); }
/// <summary> /// check whether the selected is expected, prepare necessary data /// </summary> /// <param name="selected">selected elements</param> /// <returns>whether the selected AreaReinforcement is expected</returns> private bool PreData(ElementSet selected) { //selected is not only one AreaReinforcement if (selected.Size != 1) { return(false); } foreach (Object o in selected) { m_areaRein = o as AreaReinforcement; if (null == m_areaRein) { return(false); } } //whether the selected AreaReinforcement is rectangular CurveArray curves = new CurveArray(); m_areaReinCurves = new List <AreaReinforcementCurve>(); IList <ElementId> curveIds = m_areaRein.GetBoundaryCurveIds(); foreach (ElementId o in curveIds) { AreaReinforcementCurve areaCurve = m_doc.GetElement(o) as AreaReinforcementCurve; if (null == areaCurve) { ApplicationException appEx = new ApplicationException ("There is unexpected error with selected AreaReinforcement."); throw appEx; } m_areaReinCurves.Add(areaCurve); curves.Append(areaCurve.Curve); } bool flag = GeomUtil.IsRectangular(curves); return(flag); }
/// <summary> /// Execute a manual REST request /// </summary> /// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam> /// <param name="request">The RestRequest to execute (will use client credentials)</param> public virtual T Execute <T>(IRestRequest request) where T : new() { request.OnBeforeDeserialization = resp => { // for individual resources when there's an error to make // sure that RestException props are populated if (((int)resp.StatusCode) >= 400) { // have to read the bytes so .Content doesn't get populated const string restException = "{{ \"RestException\" : {0} }}"; var content = resp.RawBytes.AsString(); //get the response content var newJson = string.Format(restException, content); resp.Content = null; resp.RawBytes = Encoding.UTF8.GetBytes(newJson.ToString(CultureInfo.InvariantCulture)); } }; // Setting auth info // SetAuthInfo(request); // Setting date format // request.DateFormat = DateFormat; var response = Client.Execute <T>(request); if (response.ErrorException != null) { const string message = "Error retrieving response. Check inner details for more info."; var marvelException = new ApplicationException(message, response.ErrorException); //throw marvelException; return(new T()); } return(response.Data); }
private AvroNode AvroDeserializeFromFile(string fileName) { AvroNode avroNode = null; try { using (var buffer = new MemoryStream()) { if (!ReadFile(buffer, fileName)) { var e = new ApplicationException("Error during file operation. Quitting method : " + fileName); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } buffer.Seek(0, SeekOrigin.Begin); using ( var reader = new SequentialReader <AvroNode>(AvroContainer.CreateReader <AvroNode>(buffer, true))) { var results = reader.Objects; if (results != null) { avroNode = (AvroNode)results.First(); } } } } catch (SerializationException ex) { Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ApplicationException("Cannot deserialize the file: " + fileName, ex); Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } return(avroNode); }
public async Task Run_ThrowsOnReportingRepositoryException() { // Arrange SetupRepositoryMethods(); var expectedException = new ApplicationException("Connection was unsuccessful"); // Override migration with an exception _externalStoredProcedureRepository .Setup(r => r.ExecuteReportingGenerateStoredProcedure()) .Throws(expectedException); Log.Logger = new LoggerConfiguration().WriteTo.TestCorrelator().CreateLogger(); using (TestCorrelator.CreateContext()) { // Act var actualException = await Assert.ThrowsAsync<ApplicationException>(async () => await _reportingDataRefreshJob.Run(null)); // Assert Assert.Equal(expectedException, actualException); AssertRepositoryMethodsCalled(); var logEvents = TestCorrelator.GetLogEventsFromCurrentContext().ToList(); AssertContainsInfoMessages(logEvents, new[] { "Starting specimen-matching uspGenerate", "Starting migration uspGenerate", "Starting reporting uspGenerate" }); Assert.Contains(logEvents, logEvent => logEvent.Level == LogEventLevel.Error && logEvent.RenderMessage() == "Error occured during reporting data refresh job" && logEvent.Exception == expectedException); AssertDoesNotContainInfoMessages(logEvents, new[] { "Finishing reporting data refresh job" }); } }
public MassiveOperationReport ConsolidateDocumentMassive(DocsPaWR.DocumentConsolidationStateEnum toState, List <MassiveOperationTarget> items) { SAAdminTool.utils.MassiveOperationReport report = new utils.MassiveOperationReport(); DocsPaWR.DocsPaWebService ws = ProxyManager.getWS(); foreach (MassiveOperationTarget mot in items) { utils.MassiveOperationReport.MassiveOperationResultEnum result = utils.MassiveOperationReport.MassiveOperationResultEnum.KO; string message = string.Empty; try { DocsPaWR.DocumentConsolidationStateInfo info = ws.ConsolidateDocumentById_AM(_userInfo, mot.Id, toState); if (info.State == toState) { result = utils.MassiveOperationReport.MassiveOperationResultEnum.OK; message = "Il documento è stato consolidato correttamente"; // Notifica evento di consolidamento del documento if (this._consolidated != null) { this._consolidated(this, new DocumentConsolidatedEventArgs { Info = info }); } } } catch (System.Web.Services.Protocols.SoapException ex) { ApplicationException originalEx = DocsPaUtils.Exceptions.SoapExceptionParser.GetOriginalException(ex); result = utils.MassiveOperationReport.MassiveOperationResultEnum.KO; message = originalEx.Message; } finally { report.AddReportRow(mot.Codice, result, message); } } return(report); }
public static bool IsValidFor(this object @this, MemberInfo mi, out Exception aggEx) { aggEx = null; ChoGuard.ArgumentNotNullOrEmpty(@this, "Target"); if (@this == null) { return(true); } var results = new List <ValidationResult>(); object surrObj = ChoSurrogateObjectCache.Default.GetSurrogateObject(@this); if (surrObj is IChoValidatable) { ((IChoValidatable)surrObj).TryValidateFor(@this, mi.Name, results); } else { //if (ChoObjectMemberMetaDataCache.Default.IsRequired(mi) && ChoType.GetMemberValue(@this, mi) == null) // results.Add(new ValidationResult("Null value found for {0} member.".FormatString(mi.Name))); var context = new ValidationContext(@this, null, null); context.MemberName = mi.Name; Validator.TryValidateValue(ChoType.GetMemberValue(@this, mi), context, results, ChoTypeDescriptor.GetPropetyAttributes <ValidationAttribute>(ChoTypeDescriptor.GetProperty <ValidationAttribute>(@this.GetType(), mi.Name))); } if (results.Count > 0) { aggEx = new ApplicationException("Failed to validate '{0}' member. {2}{1}".FormatString(mi.Name, ToString(results), Environment.NewLine)); return(false); } else { return(true); } }
public static bool IsValid(this object @this, out Exception aggEx) { aggEx = null; if (@this == null) { return(true); } var results = new List <ValidationResult>(); object surrObj = ChoSurrogateObjectCache.Default.GetSurrogateObject(@this); if (surrObj is IChoValidatable) { ((IChoValidatable)surrObj).TryValidate(@this, results); } else { foreach (MemberInfo mi in ChoType.GetMembers(@this.GetType()).Where(m => ChoType.GetMemberAttributeByBaseType <ChoMemberAttribute>(m) != null)) { //if (ChoObjectMemberMetaDataCache.Default.IsRequired(mi) && ChoType.GetMemberValue(@this, mi) == null) // results.Add(new ValidationResult("Null value found for {0} member.".FormatString(mi.Name))); } var context = new ValidationContext(@this, null, null); Validator.TryValidateObject(@this, context, results, true); } if (results.Count > 0) { aggEx = new ApplicationException("Failed to validate '{0}' object. {2}{1}".FormatString(@this.GetType().FullName, ToString(results), Environment.NewLine)); return(false); } else { return(true); } }
/// <summary> /// Execute a list of script files under transaction mode. /// </summary> /// <param name="filenames"></param> /// <param name="isolationLevel"></param> /// <param name="executeType"></param> public void ExecuteFileTran(string[] filenames, IsolationLevel?isolationLevel, ExecuteTypes executeType) { #region Sanity Checks if ((filenames == null) || (filenames.Length == 0)) { throw new ArgumentNullException("filenames"); } #endregion try { List <String> buffers = new List <string>(); for (int i = 0; i < filenames.Length; i++) { buffers.Add(StringUtil.StringArrayToString(FileUtil.ReadFile(filenames[i]))); } try { ExecuteBufferTran(buffers.ToArray(), isolationLevel, executeType); } catch (Exception ex) { // wrap more error int idx = int.Parse(ex.Data["index"].ToString()); Exception ex2 = new ApplicationException("Filename index: " + filenames[idx], ex.InnerException); ex2.Data.Add("index", idx); throw ex2; } } catch (Exception ex) { Debug.WriteLine(ex.Message); throw; } }
/// <summary> /// Returns podcasts in subscription file /// </summary> /// <returns></returns> internal List <Podcast> GetPodcasts() { //make sure we have somewhere to download to try { VerifyFolderExists(DownloadFolder); } catch (Exception ex) { var error = new ApplicationException($"Error locating download folder '{DownloadFolder}'", ex); throw error; } //read podcasts.xml file and extract subscribed podcasts from and return var podcasts = new List <Podcast>(); try { var settingsDoc = XDocument.Load($@"{Environment.CurrentDirectory}\{"Podcasts.xml"}"); var items = from item in settingsDoc.Descendants("Podcast") select new { Name = item.Element("Name")?.Value, Url = item.Element("Url")?.Value, EpisodesToKeep = item.Element("EpisodesToKeep")?.Value, Order = item.Element("Order")?.Value }; podcasts.AddRange(items.Select(item => new Podcast(item.Name, item.Url, int.Parse(item.EpisodesToKeep), (Podcast.EpisodeOrder)Enum.Parse(typeof(Podcast.EpisodeOrder), item.Order)))); } catch (Exception ex) { var error = new ApplicationException("Error retrieving subscriptions", ex); throw error; } return(podcasts); }
internal override void Write(BinaryEndianWriter bw) { base.StartLengthCheck(bw); base.Write(bw); bw.Write(_unknown, base.Root.PakFormat.EndianType); bw.Write((uint)_scriptData.Length, base.Root.PakFormat.EndianType); byte[] compScript; Lzss lz = new Lzss(); compScript = lz.Compress(_scriptData); if (compScript.Length >= _scriptData.Length) { compScript = _scriptData; } bw.Write((uint)compScript.Length, base.Root.PakFormat.EndianType); bw.Write(compScript); if (compScript.Length % 4 != 0) { for (int i = 0; i < 4 - (compScript.Length % 4); i++) { bw.Write((byte)0); } } base.WriteEnd(bw); ApplicationException ex = base.TestLengthCheck(this, bw); if (ex != null) { throw ex; } }
public override IEnumerable <EncodeJob> GetIncompleteEncodeJobs() { IEnumerable <EncodeJob> output = new EncodeJob[0]; string message = $"Exception encountered while pulling incompleted job list. {PrintDB()}"; try { var result = _jobAccessor.RetrieveIncompleteEncodeJobs(); if (result.Count() != 0) { output = result; } else { _logger?.LogInformation("No incomplete jobs found for any priority"); } } catch (DatabaseConnectionException dce) { //TODO cache logic var up = new ApplicationException(message, dce); throw up; } catch (Exception ex) { if (null != _logger) { _logger.LogError(ex, message); } else { ex.Data["message"] = message; throw ex; } } return(output); }
public AvroConfiguration AvroDeseriaizeFromFile(string fileName) { AvroConfiguration avroConf = null; try { using (var buffer = new MemoryStream()) { if (!ReadFile(buffer, fileName)) { var e = new ApplicationException("Error during file operation. Quitting method : " + fileName); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } buffer.Seek(0, SeekOrigin.Begin); //AvroSerializerSettings settings = new AvroSerializerSettings(); //settings.Resolver = new AvroConfigurationResolver(); //using (var reader = new SequentialReader<AvroConfiguration>(AvroContainer.CreateReader<AvroConfiguration>(buffer, true, settings, new CodecFactory()))) using (var reader = new SequentialReader <AvroConfiguration>(AvroContainer.CreateReader <AvroConfiguration>(buffer, true))) { var results = reader.Objects; if (results != null) { avroConf = (AvroConfiguration)results.First(); } } } } catch (SerializationException ex) { Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Caught(ex, Level.Error, LOGGER); var e = new ApplicationException("Cannot deserialize the file: " + fileName, ex); Org.Apache.REEF.Utilities.Diagnostics.Exceptions.Throw(e, LOGGER); } return(avroConf); }
public override void DisplayError(Exception ex, string action = "", ErrorLevel level = ErrorLevel.Undefined) { if (action == null) { action = ""; } if (ex == null) { ex = new ApplicationException("Unknown error"); } var wr = global::System.Console.Error; wr.WriteLine("*** " + DateTime.Now.ToString() + " ***"); if (action.Length > 0) { wr.WriteLine("Action: *" + action + "*"); } wr.WriteLine(ex.ToString()); wr.WriteLine("Module: " + ex.Source); if (ex.HelpLink != null) { wr.WriteLine("Help link: " + ex.HelpLink); } if (ex.Data != null && ex.Data.Count > 0) { wr.WriteLine("-- Additional data --"); foreach (object val in ex.Data.Keys) { wr.WriteLine(val + ": " + ex.Data[val]); } wr.WriteLine("----------------------"); } wr.WriteLine("***********************************"); wr.WriteLine(); }
public void FaultedFutureTest() { var thrown = new ApplicationException(); var source = new TaskCompletionSource <int>(); source.TrySetException(thrown); var f = source.Task; AggregateException ex = null; try { f.Wait(); } catch (AggregateException e) { ex = e; } Assert.IsNotNull(ex); Assert.AreEqual(thrown, ex.InnerException); Assert.AreEqual(thrown, f.Exception.InnerException); Assert.AreEqual(TaskStatus.Faulted, f.Status); ex = null; try { GC.KeepAlive(f.Result); } catch (AggregateException e) { ex = e; } Assert.IsNotNull(ex); Assert.AreEqual(TaskStatus.Faulted, f.Status); Assert.AreEqual(thrown, f.Exception.InnerException); Assert.AreEqual(thrown, ex.InnerException); }
public override IEnumerable <EncodeJob> GetJobsByVideoName(string videoName) { IEnumerable <EncodeJob> output = new EncodeJob[0]; string message = $"Exception encountered while pulling jobs with video name: {videoName} {PrintDB()}"; try { var result = _jobAccessor.RetrieveCompleteEncodeJobsByVideoName(videoName); if (result.Count() != 0) { output = result; } else { _logger?.LogInformation($"No jobs found with video name: {videoName}"); } } catch (DatabaseConnectionException dce) { //TODO cache logic var up = new ApplicationException(message, dce); throw up; } catch (Exception ex) { if (null != _logger) { _logger.LogError(ex, message); } else { ex.Data["message"] = message; throw ex; } } return(output); }
public bool Update(EntRolesVista entidad) { bool respuesta = false; try { AbrirConexion(); var sql = "execute procedure dml_roles_vista (?,?,?,?);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_rol_vista; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_rol; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_vista; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Roles Vista"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Roles Vista"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public Services.Packages.Log.Security.ApplicationExceptionAccessControlListCollection GetACLs(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("GetACLs", new object[] {_ApplicationException,SessionToken}); return ((Services.Packages.Log.Security.ApplicationExceptionAccessControlListCollection)(results[0])); }
public void SetInnerExceptions(ApplicationException _ApplicationException, Services.Packages.Log.ApplicationExceptionCollection _InnerExceptions, string SessionToken) { this.Invoke("GetInnerExceptions", new object[] {_ApplicationException,SessionToken}); return; }
public Services.Packages.Log.ApplicationExceptionCollection GetInnerExceptions(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("GetInnerExceptions", new object[] {_ApplicationException,SessionToken}); return ((Services.Packages.Log.ApplicationExceptionCollection)(results[0])); }
public void SetOwner(ApplicationException _ApplicationException, Services.Packages.Security.ModelUser _Owner, string SessionToken) { this.Invoke("GetOwner", new object[] {_ApplicationException,SessionToken}); return; }
public void DeleteObject(ApplicationException _ApplicationException, string SessionToken) { if (!ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Delete")) throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Delete(); }
/// <summary> /// Save a post /// </summary> /// <param name="post">Post that will be saved</param> public void SavePost(Post post) { if (post.IsValid) { if (post.PostId == 0) //If PostId = 0 -> New post { PostDAL.InsertPost(post); } else { PostDAL.UpdatePost(post); } } else { ApplicationException ex = new ApplicationException(post.Error); ex.Data.Add("Post", post); throw ex; } }
public void SetACLs(ApplicationException _ApplicationException, Services.Packages.Log.Security.ApplicationExceptionAccessControlListCollection _ACLs, string SessionToken) { this.Invoke("GetACLs", new object[] {_ApplicationException,SessionToken}); return; }
public void SetApiKey(ApplicationException _ApplicationException, Services.Packages.ApiKey _ApiKey, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ //* _ApiKey.Reload(); if (_ApiKey.Exists && !Services.Packages.Security.ApiKeySecureService.CheckAccessImp(_ApiKey, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_ApiKey.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Create ApplicationExceptionsLogged")) throw new UnauthorizedAccessException("Access Denied"); //*/ _ApplicationException.ApiKey = _ApiKey; _ApplicationException.Update(); }
public bool Exists(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("Exists", new object[] {_ApplicationException,SessionToken}); return ((bool)(results[0])); }
public ApplicationException Reload(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("Reload", new object[] {_ApplicationException,SessionToken}); return ((ApplicationException)(results[0])); }
public void SetACLs(ApplicationException _ApplicationException, Services.Packages.Log.Security.ApplicationExceptionAccessControlListCollection _ACLs, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ /* _ACLs.Reload(); if (_ACLs.Exists && !Services.Packages.Log.Security.Security.ApplicationExceptionAccessControlListSecureService.CheckAccessImp(_ACLs, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_ACLs.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Create ACLs")) throw new UnauthorizedAccessException("Access Denied"); //*/ _ApplicationException.ACLs = _ACLs; _ApplicationException.Update(); }
public Services.Packages.Log.Security.ApplicationExceptionAccessControlListCollection GetACLs(ApplicationException _ApplicationException, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ /* if (!Services.Packages.Log.Security.Security.ApplicationExceptionAccessControlListSecureService.CheckAccessImp(_ApplicationException.ACLs, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); //*/ return _ApplicationException.ACLs; }
public void SetInnerExceptions(ApplicationException _ApplicationException, Services.Packages.Log.ApplicationExceptionCollection _InnerExceptions, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ /* _InnerExceptions.Reload(); if (_InnerExceptions.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_InnerExceptions, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_InnerExceptions.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Create InnerExceptions")) throw new UnauthorizedAccessException("Access Denied"); //*/ _ApplicationException.InnerExceptions = _InnerExceptions; _ApplicationException.Update(); }
public void SetOwner(ApplicationException _ApplicationException, Services.Packages.Security.ModelUser _Owner, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ //* _Owner.Reload(); if (_Owner.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); else if (!_Owner.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Create ApplicationExceptionOwning")) throw new UnauthorizedAccessException("Access Denied"); //*/ _ApplicationException.Owner = _Owner; _ApplicationException.Update(); }
public Services.Packages.Security.ModelUser GetOwner(ApplicationException _ApplicationException, string SessionToken) { _ApplicationException.Reload(); //* if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Traverse")) throw new UnauthorizedAccessException("Access Denied"); //*/ //* if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_ApplicationException.Owner, SessionToken, "Read")) throw new UnauthorizedAccessException("Access Denied"); //*/ return _ApplicationException.Owner; }
public ApplicationException CreateFromOwner(System.Int32 __Id, Services.Packages.Security.ModelUser _Owner, string SessionToken) { ModelSession session = ApplicationExceptionSecureService.CheckSessionImp(SessionToken); ApplicationException _ApplicationException = new ApplicationException(__Id); if (!_ApplicationException.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Create ApplicationExceptionOwning")) throw new UnauthorizedAccessException("Access Denied"); else if (_ApplicationException.Exists && !ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); // ApplicationException _ApplicationException = ApplicationException.CreateApplicationException(__Id); _ApplicationException.Owner = session.User; _ApplicationException.Owner = _Owner; _ApplicationException.Update(); return _ApplicationException; }
public void Delete(System.Int32 __Id, string SessionToken) { ApplicationException _ApplicationException = new ApplicationException(__Id); if (!ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Delete")) throw new UnauthorizedAccessException("Access Denied"); ApplicationException.DeleteApplicationException(__Id); }
public void DeleteObject(ApplicationException _ApplicationException, string SessionToken) { this.Invoke("DeleteObject", new object[] {_ApplicationException,SessionToken}); return; }
public void CreateObjectFromParentException(ApplicationException _ApplicationException, Services.Packages.Log.ApplicationException _ParentException, string SessionToken) { ModelSession session = ApplicationExceptionSecureService.CheckSessionImp(SessionToken); //if (!Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ParentException, SessionToken, "Create InnerExceptions")) // throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Reload(); if (!_ApplicationException.Exists && !Services.Packages.Log.Security.ApplicationExceptionSecureService.CheckAccessImp(_ParentException, SessionToken, "Create InnerExceptions")) throw new UnauthorizedAccessException("Access Denied"); else if (_ApplicationException.Exists && !ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Owner = session.User; _ApplicationException.ParentException = _ParentException; _ApplicationException.Create(); }
public Services.Packages.ApiKey GetApiKey(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("GetApiKey", new object[] {_ApplicationException,SessionToken}); return ((Services.Packages.ApiKey)(results[0])); }
public void SetApiKey(ApplicationException _ApplicationException, Services.Packages.ApiKey _ApiKey, string SessionToken) { this.Invoke("GetApiKey", new object[] {_ApplicationException,SessionToken}); return; }
/// <summary> /// Save comment /// </summary> /// <param name="member">Comment to save</param> public void SaveComment(Comment comment) { if (comment.IsValid) { if (comment.CommentId == 0) { CommentDAL.InsertComment(comment); } else { CommentDAL.UpdateComment(comment); } } else { ApplicationException ex = new ApplicationException(comment.Error); ex.Data.Add("Comment", comment); Service.WriteToLog(ex.ToString(), (int)Membership.GetUser().ProviderUserKey); throw ex; } }
public void SetParentException(ApplicationException _ApplicationException, Services.Packages.Log.ApplicationException _ParentException, string SessionToken) { this.Invoke("GetParentException", new object[] {_ApplicationException,SessionToken}); return; }
public void HttpError_ExceptionType_RoundTrips() { ApplicationException exception = new ApplicationException("HelloWorld"); Assert.Reflection.Property( new HttpError(exception, includeErrorDetail: true), e => e.ExceptionType, expectedDefaultValue: exception.GetType().FullName, allowNull: true, roundTripTestValue: "HelloAgain"); }
public Services.Packages.Security.ModelUser GetOwner(ApplicationException _ApplicationException, string SessionToken) { object[] results = this.Invoke("GetOwner", new object[] {_ApplicationException,SessionToken}); return ((Services.Packages.Security.ModelUser)(results[0])); }
public void CreateObjectFromOwner(ApplicationException _ApplicationException, Services.Packages.Security.ModelUser _Owner, string SessionToken) { ModelSession session = ApplicationExceptionSecureService.CheckSessionImp(SessionToken); //if (!Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Create ApplicationExceptionOwning")) // throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Reload(); if (!_ApplicationException.Exists && !Services.Packages.Security.Security.ModelUserSecureService.CheckAccessImp(_Owner, SessionToken, "Create ApplicationExceptionOwning")) throw new UnauthorizedAccessException("Access Denied"); else if (_ApplicationException.Exists && !ApplicationExceptionSecureService.CheckAccessImp(_ApplicationException, SessionToken, "Update")) throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Owner = session.User; _ApplicationException.Owner = _Owner; _ApplicationException.Create(); }
public void CreateObject(ApplicationException _ApplicationException, string SessionToken) { ModelSession session = ApplicationExceptionSecureService.CheckSessionImp(SessionToken); if (!ApplicationExceptionSecureService.CheckUserRightsImp(session.User.Name, "Create " + typeof(ApplicationException).FullName)) throw new UnauthorizedAccessException("Access Denied"); _ApplicationException.Owner = session.User; _ApplicationException.Create(); }