// // Add an error if there are attributes that have not been examined, // and are therefore unrecognized. // internal void VerifyNoUnrecognizedAttributes(ExceptionAction action) { if (_reader.MoveToNextAttribute()) { AddErrorUnrecognizedAttribute(action); } }
public void Add(Type exceptionType, ExceptionAction exceptionAction) { ExceptionCell[] newExceptionArray; if (exceptionArray.Length > 0) { foreach (var exception_for in exceptionArray) { if (exceptionType == exception_for.ExceptionType) { throw new ExceptionListException("This type of exception already in the exception list"); } } newExceptionArray = new ExceptionCell[exceptionArray.Length + 1]; for (int i = 0; i < exceptionArray.Length; i++) { newExceptionArray[i] = exceptionArray[i]; } newExceptionArray[exceptionArray.Length] = new ExceptionCell(exceptionType, exceptionAction); exceptionArray = newExceptionArray; return; } newExceptionArray = new ExceptionCell[1]; newExceptionArray[0] = new ExceptionCell(exceptionType, exceptionAction); exceptionArray = newExceptionArray; }
public ExceptionList(ExceptionAction defaultExceptionAction) { exceptionArray = new ExceptionCell[1]; exceptionArray[0] = new ExceptionCell { ExceptionType = typeof(Exception), ExceptionAction = defaultExceptionAction }; }
// Verify and Retrieve the Boolean Attribute. If it is not // a valid value then log an error and set the value to a given default. internal void VerifyAndGetBooleanAttribute( ExceptionAction action, bool defaultValue, out bool newValue) { if (Reader.Value == "true") { newValue = true; } else { if (Reader.Value == "false") { newValue = false; } else { // Unrecognized value newValue = defaultValue; ConfigurationErrorsException ex = new ConfigurationErrorsException( string.Format(SR.Config_invalid_boolean_attribute, Reader.Name), this); SchemaErrors.AddError(ex, action); } } }
internal void AddErrorUnrecognizedElement(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.GetString(SR.Config_base_unrecognized_element), this); SchemaErrors.AddError(ex, action); }
internal void AddErrorRequiredAttribute(string attrib, ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.GetString(SR.Config_missing_required_attribute, attrib, _reader.Name), this); SchemaErrors.AddError(ex, action); }
internal void AddErrorUnrecognizedAttribute(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( string.Format(SR.Config_base_unrecognized_attribute, Reader.Name), this); SchemaErrors.AddError(ex, action); }
internal void AddErrorReservedAttribute(ExceptionAction action) { ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.GetString(SR.Config_reserved_attribute, _reader.Name), this); SchemaErrors.AddError(ex, action); }
internal bool VerifyRequiredAttribute(object o, string attrName, ExceptionAction action) { if (o == null) { this.AddErrorRequiredAttribute(attrName, action); return(false); } return(true); }
internal void StrictSkipToNextElement(ExceptionAction action) { this._reader.Skip(); while (!this._reader.EOF && (this._reader.NodeType != XmlNodeType.Element)) { this.VerifyIgnorableNodeType(action); this._reader.Read(); } }
public bool GenericExceptionCatchPoint(string exception, out ExceptionAction action) { if (generic_exc_handler != null) { return(generic_exc_handler(exception, out action)); } action = ExceptionAction.None; return(false); }
internal void VerifyIgnorableNodeType(ExceptionAction action) { XmlNodeType nodeType = this._reader.NodeType; if ((nodeType != XmlNodeType.Comment) && (nodeType != XmlNodeType.EndElement)) { ConfigurationException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_base_unrecognized_element"), this); this.SchemaErrors.AddError(ce, action); } }
internal void StrictReadToNextElement(ExceptionAction action) { while (this._reader.Read()) { if (this._reader.NodeType == XmlNodeType.Element) { return; } this.VerifyIgnorableNodeType(action); } }
public BasicExceptionHandler(ExpressionRuleData data) { _action = data.Action; if (data.UseRegex) { _regexExpression = new Regex(data.Expression); } else { _simpleExpression = data.Expression; } }
internal void VerifyAndGetNonEmptyStringAttribute(ExceptionAction action, out string newValue) { if (!string.IsNullOrEmpty(this._reader.Value)) { newValue = this._reader.Value; } else { newValue = null; ConfigurationException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Empty_attribute", new object[] { this._reader.Name }), this); this.SchemaErrors.AddError(ce, action); } }
// // Read to the next start element, and verify that all XML nodes read are permissible. // internal void StrictReadToNextElement(ExceptionAction action) { while (_reader.Read()) { // optimize for the common case if (_reader.NodeType == XmlNodeType.Element) { return; } VerifyIgnorableNodeType(action); } }
// // Add an error if the node type is not permitted by the configuration schema. // internal void VerifyIgnorableNodeType(ExceptionAction action) { XmlNodeType nodeType = _reader.NodeType; if (nodeType != XmlNodeType.Comment && nodeType != XmlNodeType.EndElement) { ConfigurationException ex = new ConfigurationErrorsException( SR.GetString(SR.Config_base_unrecognized_element), this); SchemaErrors.AddError(ex, action); } }
internal void StrictSkipToOurParentsEndElement(ExceptionAction action) { int depth = this._reader.Depth; while (this._reader.Depth >= depth) { this._reader.Skip(); } while (!this._reader.EOF && (this._reader.NodeType != XmlNodeType.EndElement)) { this.VerifyIgnorableNodeType(action); this._reader.Read(); } }
// // StrictSkipToOurParentsEndElement // // Skip until we hit the end element for our parent, and verify // that nodes at the parent level are permissible. // internal void StrictSkipToOurParentsEndElement(ExceptionAction action) { int currentDepth = _reader.Depth; // Skip everything at out current level while (_reader.Depth >= currentDepth) { _reader.Skip(); } while (!_reader.EOF && _reader.NodeType != XmlNodeType.EndElement) { VerifyIgnorableNodeType(action); _reader.Read(); } }
// // Add a configuration Error. // internal void AddError(ConfigurationException ce, ExceptionAction action) { switch (action) { case ExceptionAction.Global: ErrorsHelper.AddError(ref _errorsAll, ce); ErrorsHelper.AddError(ref _errorsGlobal, ce); break; case ExceptionAction.NonSpecific: ErrorsHelper.AddError(ref _errorsAll, ce); break; case ExceptionAction.Local: ErrorsHelper.AddError(ref _errorsLocal, ce); break; } }
internal void VerifyAndGetBooleanAttribute(ExceptionAction action, bool defaultValue, out bool newValue) { if (this._reader.Value == "true") { newValue = true; } else if (this._reader.Value == "false") { newValue = false; } else { newValue = defaultValue; ConfigurationErrorsException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_invalid_boolean_attribute", new object[] { this._reader.Name }), this); this.SchemaErrors.AddError(ce, action); } }
internal void VerifyAndGetNonEmptyStringAttribute(ExceptionAction action, out string newValue) { if (!String.IsNullOrEmpty(_reader.Value)) { newValue = _reader.Value; } else { newValue = null; ConfigurationException ex = new ConfigurationErrorsException( SR.GetString(SR.Empty_attribute, _reader.Name), this); SchemaErrors.AddError(ex, action); } }
internal void AddError(ConfigurationException ce, ExceptionAction action) { switch (action) { case ExceptionAction.Global: ErrorsHelper.AddError(ref _errorsAll, ce); ErrorsHelper.AddError(ref _errorsGlobal, ce); break; case ExceptionAction.NonSpecific: ErrorsHelper.AddError(ref _errorsAll, ce); break; case ExceptionAction.Local: ErrorsHelper.AddError(ref _errorsLocal, ce); break; } }
/// <summary> /// Verify and Retrieve the Boolean Attribute. If it is not /// a valid value then log an error and set the value to a given default. /// </summary> internal void VerifyAndGetBooleanAttribute( ExceptionAction action, bool defaultValue, out bool newValue) { switch (Reader.Value) { case "true": newValue = true; break; case "false": newValue = false; break; default: newValue = defaultValue; SchemaErrors.AddError( new ConfigurationErrorsException(string.Format(SR.Config_invalid_boolean_attribute, Reader.Name), this), action); break; } }
static protected void VerifySectionName(string name, XmlUtil xmlUtil, ExceptionAction action, bool allowImplicit) { try { VerifySectionName(name, (IConfigErrorInfo) xmlUtil, allowImplicit); } catch (ConfigurationErrorsException ce) { xmlUtil.SchemaErrors.AddError(ce, action); } }
public ExceptionCell(Type exceptionType, ExceptionAction exceptionAction) { ExceptionType = exceptionType; ExceptionAction = exceptionAction; }
// // Add an error if the retrieved attribute is null, // and therefore not present. // internal bool VerifyRequiredAttribute( object o, string attrName, ExceptionAction action) { if (o == null) { AddErrorRequiredAttribute(attrName, action); return false; } else { return true; } }
// // Skip this element and its children, then read to next start element, // or until we hit end of file. Verify that nodes that are read after the // skipped element are permissible. // internal void StrictSkipToNextElement(ExceptionAction action) { _reader.Skip(); while (!_reader.EOF && _reader.NodeType != XmlNodeType.Element) { VerifyIgnorableNodeType(action); _reader.Read(); } }
internal void AddErrorUnrecognizedElement(ExceptionAction action) { ConfigurationErrorsException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_base_unrecognized_element"), this); this.SchemaErrors.AddError(ce, action); }
internal void AddErrorUnrecognizedAttribute(ExceptionAction action) { ConfigurationErrorsException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_base_unrecognized_attribute", new object[] { this._reader.Name }), this); this.SchemaErrors.AddError(ce, action); }
public static void Log(this Exception exception, HttpContext context, ExceptionAction action = ExceptionAction.Enqueue) { Log(exception, context, string.Empty, action); }
public static void Log(this Exception exception, HttpContext context, string customMessage, ExceptionAction action = ExceptionAction.Enqueue) { #if DEBUG return; #endif var url = "Not available"; var urlreferer = "Not available"; if (context != null) { url = context.Request.Url.ToString(); } if (context != null && context.Request.UrlReferrer != null) { urlreferer = context.Request.UrlReferrer.ToString(); } var message = new AppException { CustomMessage = string.IsNullOrWhiteSpace(customMessage) ? "AtomicLimbs.Error" : customMessage, Exception = exception, Url = url, UrlReferrer = urlreferer, }; try { if (ExceptionAction.Enqueue.Equals(action) || ExceptionAction.SendMailAndEnqueue.Equals(action)) { AzureQueue.Enqueue(message); } } catch (Exception) { //estamos en la B, error del error } try { if (ExceptionAction.SendMail.Equals(action) || ExceptionAction.SendMailAndEnqueue.Equals(action)) { var mailserver = ConfigurationManager.AppSettings["Mail.Server"]; var username = ConfigurationManager.AppSettings["Mail.Username"]; var password = ConfigurationManager.AppSettings["Mail.Password"]; var from = ConfigurationManager.AppSettings["Mail.From"]; var adminmail = ConfigurationManager.AppSettings["AdminEmails"]; var mailSender = new GeneralMailSender(mailserver, username, password); var mailMessage = new System.Net.Mail.MailMessage(from, adminmail?.Split(',')[0] ?? throw new InvalidOperationException(), message.CustomMessage, message.Url + "\n\n" + message.UrlReferrer + "\n\n" + message.Exception + "\n\n" + message.LogMessage + "\n\n" + message.Message + "\n\n" + message.StackTrace + "\n\n" + message.InnerExceptionMessage); // si el mensaje es null significa que el maker controló algunas situaciones y no hay nada para enviar y el mensaje se puede remover de la queue mailSender.Send(mailMessage); } } catch (Exception e) { //estamos en la B, error del error } try { var ai = new TelemetryClient(); ai.TrackException(exception); } catch (Exception) { //estamos en la B, error del error } }
/// <summary> /// Add an error if the retrieved attribute is null, and therefore not present. /// </summary> internal bool VerifyRequiredAttribute(object requiredAttribute, string attrName, ExceptionAction action) { if (requiredAttribute == null) { AddErrorRequiredAttribute(attrName, action); return(false); } else { return(true); } }
public void SetDefaultProcess(ExceptionAction exceptionAction) { exceptionArray[0].ExceptionAction = exceptionAction; }
internal void AddErrorRequiredAttribute(string attrib, ExceptionAction action) { ConfigurationErrorsException ce = new ConfigurationErrorsException(System.Configuration.SR.GetString("Config_missing_required_attribute", new object[] { attrib, this._reader.Name }), this); this.SchemaErrors.AddError(ce, action); }
// VerifyAndGetBooleanAttribute // // Verify and Retrieve the Boolean Attribute. If it is not // a valid value then log an error and set the value to a given default. // internal void VerifyAndGetBooleanAttribute( ExceptionAction action, bool defaultValue, out bool newValue) { if (_reader.Value == "true") { newValue = true; } else if (_reader.Value == "false") { newValue = false; } else { // Unrecognized value newValue = defaultValue; ConfigurationErrorsException ex = new ConfigurationErrorsException( SR.GetString(SR.Config_invalid_boolean_attribute, _reader.Name), this); SchemaErrors.AddError(ex, action); } }
dbgExceptionAction ConvertExceptionAction(ExceptionAction action) { switch (action) { case ExceptionAction.Default: return dbgExceptionAction.dbgExceptionActionDefault; case ExceptionAction.Ignore: return dbgExceptionAction.dbgExceptionActionContinue; case ExceptionAction.Break: return dbgExceptionAction.dbgExceptionActionBreak; case ExceptionAction.Continue: return dbgExceptionAction.dbgExceptionActionContinue; default: throw new ArgumentException(); } }
public ExceptionBehaviorAttribute(Type exceptionType, ExceptionAction action) { this.exceptionType = exceptionType; this.action = action; }
//TODO: Return NOT void. Problem with ExceptionMiddleware public static async void Log(this Exception exception, HttpContext context, Guid idGuid, string source = "Microservices", string customMessage = "CienciaArgentina.Error", ExceptionAction action = ExceptionAction.Enqueue) { var url = "Not available"; var urlreferer = "Not available"; if (context != null) { var request = context.Request; urlreferer = context.Request.Headers["Referer"].ToString(); url = $"{request.Scheme}://" + $"{request.Host.ToUriComponent()}" + $"{request.PathBase.ToUriComponent()}" + $"{request.Path.ToUriComponent()}" + $"{request.QueryString.ToUriComponent()}"; if (context.User?.Identity != null && context.User.Identity.IsAuthenticated) { customMessage += $"| LoggedUser: {context.User.Identity.Name}"; } } var message = new AppException { IdFront = idGuid.ToString(), CustomMessage = customMessage, Message = exception.Message, Detail = exception.StackTrace, Url = url, UrlReferrer = urlreferer, Source = source }; try { if (ExceptionAction.Enqueue.Equals(action) || ExceptionAction.SendMailAndEnqueue.Equals(action)) { await AzureQueue.Enqueue(message); } } catch (Exception ex) { Console.WriteLine(ex.Message); //estamos en la B, error del error } try { if (ExceptionAction.SendMail.Equals(action) || ExceptionAction.SendMailAndEnqueue.Equals(action)) { //TODO: Hacer mail //var mailserver = ConfigurationManager.AppSettings["Mail.Server"]; //var username = ConfigurationManager.AppSettings["Mail.Username"]; //var password = ConfigurationManager.AppSettings["Mail.Password"]; //var from = ConfigurationManager.AppSettings["Mail.From"]; //var adminmail = ConfigurationManager.AppSettings["AdminEmails"]; //var mailSender = new GeneralMailSender(mailserver, username, password); //var mailMessage = new System.Net.Mail.MailMessage(from, adminmail?.Split(',')[0] ?? throw new InvalidOperationException(), message.CustomMessage, message.Url + "\n\n" + message.UrlReferrer + "\n\n" + message.Exception); // si el mensaje es null significa que el maker controló algunas situaciones y no hay nada para enviar y el mensaje se puede remover de la queue //mailSender.Send(mailMessage); } } catch (Exception ex) { Console.WriteLine(ex.Message); } try { var ai = new TelemetryClient(); ai.TrackException(exception); } catch (Exception) { //estamos en la B, error del error } }
public bool GenericExceptionCatchPoint(string exception, out ExceptionAction action) { if (generic_exc_handler != null) return generic_exc_handler (exception, out action); action = ExceptionAction.None; return false; }
public static void Log(this Exception exception, ExceptionAction action = ExceptionAction.Enqueue) { Log(exception, null, string.Empty, action); }