/// <summary> /// Write log /// </summary> /// <param name="message">Usage mode: ex.ToString()</param> /// <param name="typeError">Error type enum </param> public void WriteLog(ErrorTypeEnum ErrorType, int idEvento, string message) { string logFilePath = System.Configuration.ConfigurationManager.AppSettings["LogFileNamePath"] ?? ""; string logMapping = System.Configuration.ConfigurationManager.AppSettings["LogMapping"].ToLower() ?? "all"; logFilePath = logFilePath.Replace(".txt", string.Format("{0}{1}{2}.txt", DateTime.Now.Day, DateTime.Now.Month, DateTime.Now.Year)); // Verifica el nivel de Log a registrar if (System.String.Compare(logMapping.ToLower(), "none", System.StringComparison.Ordinal) == 0) { } else { if (System.String.Compare(logMapping.ToLower(), "all", System.StringComparison.Ordinal) == 0) // Registra todos los Logs { WriteToLogFile(logFilePath, ErrorType.ToString() + " " + idEvento + ": " + message); } else { // Registra unicamente el nivel indicado if (System.String.Compare(ErrorType.ToString().ToLower(), logMapping, System.StringComparison.Ordinal) == 0) { WriteToLogFile(logFilePath, ErrorType.ToString() + " " + idEvento + ": " + message); } } } }
public KnownException(ErrorTypeEnum errorType, string methotName, Exception exception) { ErrorTypeProp = errorType; ExceptionMessageProp = exception.Message; ExceptionProp = exception; MethotNameProp = methotName; }
void myad_BannerError(object sender, ErrorTypeEnum e) { string errorstr = ""; switch (e) { case ErrorTypeEnum.NetworkErrorOrServerError: errorstr = "Network Error"; break; case ErrorTypeEnum.AppKeyOrAppSecretError: errorstr = "Appkey or Appsecret Error"; break; case ErrorTypeEnum.ResponseError: errorstr = "Service Error"; break; case ErrorTypeEnum.Unknown: break; default: break; } }
public KnownException(ErrorTypeEnum errorType, string methotName, string exceptionMessage) : base(exceptionMessage) { MethotNameProp = methotName; ExceptionMessageProp = exceptionMessage; ErrorTypeProp = errorType; }
public RequestWarningException(ErrorTypeEnum errorTypeProp, string exceptionCode, string message, Exception exception) : base(message) { ErrorTypeProp = errorTypeProp; ExceptionMessage = message; ExceptionCode = exceptionCode; ExceptionProp = exception; }
public ResponseData(ErrorTypeEnum errorType) { IsError = true; Error = new ErrorResponseData() { ErrorType = errorType }; }
public FattalDbException(ErrorTypeEnum errorType, string methotName, string exceptionMessage, Exception ex) : base(exceptionMessage) { ExceptionProp = ex; MethotNameProp = methotName; ExceptionMessageProp = exceptionMessage; ErrorTypeProp = errorType; }
public KnownException(ErrorTypeEnum errorType, string methotName, string message, Exception exception) : base(message, exception) { MethotNameProp = methotName; ErrorTypeProp = errorType; ExceptionMessageProp = message; ExceptionProp = exception; }
public DataspinError(ErrorTypeEnum errorType, string message, string stackTrace = null, DataspinWebRequest request = null) { this.errorType = errorType; this.message = message; this.stackTrace = stackTrace; this.request = request; DataspinManager.Instance.LogError(this.ToString()); DataspinManager.Instance.FireErrorEvent(this); }
public SearchException(ErrorTypeEnum type) { ErrorType = type; switch (ErrorType) { case ErrorTypeEnum.INVALID_FIELDS: _message = "A field that does not belong to the specified DatabaseTable was used as a search field."; break; case ErrorTypeEnum.MISSING_DATABASE: _message = "A database manager must be specified to use a Searcher."; break; case ErrorTypeEnum.MISSING_FIELDS: _message = "No fields have been defined to search over."; break; } }
/// <summary> /// 备案错误推送消息 /// </summary> /// <param name="sendProcessDto">推送消息</param> /// <param name="errorStatus">错误类型</param> /// <param name="errorRemark">错误信息</param> /// <returns></returns> public void RecordErrorProcess(SendProcessDto sendProcessDto, ErrorTypeEnum errorType, string errorRemark) { if (sendProcessDto == null) { //LogHelper.Error.Write("RecordErrorProcess", "参数错误"); return; } ProcessHistoryDto processHistoryDto = _mapper.Map <ProcessHistoryDto>(sendProcessDto); processHistoryDto.Id = 0; processHistoryDto.SendStatus = (int)SendStatusEnum.Failure; processHistoryDto.ErrorType = (int)errorType; processHistoryDto.Remark = errorRemark; AddProcessHistoryDomainModel model = _mapper.Map <AddProcessHistoryDomainModel>(processHistoryDto); int row = _pushProcessHistoryService.InsertProcessHistoryAsync(model).Result; }
internal void LogErrorRemote(string userId, ErrorTypeEnum errorType, Exception ex) { try { PostResponseSimple <string>("/api/Misc/LogRemoteError", new PostLogRemoteErrorRequest { UserId = userId, ErrorType = errorType, Exception = ex.ToString() }); } catch { // Ignore error } }
//初始化 private void Initialize() { m_id = System.Guid.NewGuid().ToString(); m_errorType = ErrorTypeEnum.UnknownError; m_machineName = Environment.MachineName; m_errorTime = DateTime.Now; if (HttpContext.Current != null) { m_visitPage = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port.ToString() + HttpContext.Current.Request.Path; } else { m_visitPage = VISIPAGE_ERROR; } m_desc = ""; }
public SearchException(ErrorTypeEnum type) { ErrorType = type; switch (ErrorType) { case ErrorTypeEnum.INVALID_FIELDS: _message = "A field that does not belong to the specified DatabaseTable was used as a search field."; break; case ErrorTypeEnum.MISSING_DATABASE: _message = "A database manager must be specified to use a Searcher."; break; case ErrorTypeEnum.MISSING_FIELDS: _message = "No fields have been defined to search over."; break; } }
void myad_BannerError(object sender, ErrorTypeEnum e) { string errorstr = ""; switch (e) { case ErrorTypeEnum.NetworkErrorOrServerError: errorstr = "Network Error"; break; case ErrorTypeEnum.AppKeyOrAppSecretError: errorstr = "Appkey or Appsecret Error"; break; case ErrorTypeEnum.ResponseError: errorstr = "Service Error"; break; case ErrorTypeEnum.Unknown: break; default: break; } }
/// <summary> /// Initializes a new instance of the <see cref="InlineResponse422" /> class. /// </summary> /// <param name="data">data (required).</param> /// <param name="errorType">errorType (required).</param> public InlineResponse422(string data, ErrorTypeEnum errorType = default(ErrorTypeEnum)) { // to ensure "data" is required (not null) if (data == null) { throw new InvalidDataException("data is a required property for InlineResponse422 and cannot be null"); } else { this.Data = data; } // to ensure "errorType" is required (not null) if (errorType == null) { throw new InvalidDataException("errorType is a required property for InlineResponse422 and cannot be null"); } else { this.ErrorType = errorType; } }
/// <summary> /// Initializes a new instance of the <see cref="RequestValidationError" /> class. /// </summary> /// <param name="data">data (required).</param> /// <param name="errorType">errorType (required).</param> public RequestValidationError(string data = default(string), ErrorTypeEnum errorType = default(ErrorTypeEnum)) { // to ensure "data" is required (not null) if (data == null) { throw new InvalidDataException("data is a required property for RequestValidationError and cannot be null"); } else { this.Data = data; } // to ensure "errorType" is required (not null) if (errorType == null) { throw new InvalidDataException("errorType is a required property for RequestValidationError and cannot be null"); } else { this.ErrorType = errorType; } }
/// <summary> /// Initializes a new instance of the <see cref="InternalServerError" /> class. /// </summary> /// <param name="data">data (required).</param> /// <param name="errorType">errorType (required).</param> public InternalServerError(Object data = default(Object), ErrorTypeEnum errorType = default(ErrorTypeEnum)) { // to ensure "data" is required (not null) if (data == null) { throw new InvalidDataException("data is a required property for InternalServerError and cannot be null"); } else { this.Data = data; } // to ensure "errorType" is required (not null) if (errorType == null) { throw new InvalidDataException("errorType is a required property for InternalServerError and cannot be null"); } else { this.ErrorType = errorType; } }
public ErrorNotifier(string msg, ErrorTypeEnum type) { this.Msg = msg; switch (type) { case ErrorTypeEnum.NotFound: Code = 402; break; case ErrorTypeEnum.Failur: Code = 401; break; case ErrorTypeEnum.NotMatch: Code = 400; break; default: Code = 404; break; } }
/// <summary> /// Translate from <see cref="ErrorTypeEnum" /> to a string. /// </summary> /// <param name="errorType">The error type.</param> /// <returns>A string representation of the <paramref name="errorType" />.</returns> public static string TranslateErrorType(ErrorTypeEnum errorType) { switch (errorType) { case ErrorTypeEnum.NotFound: return(NotFound); case ErrorTypeEnum.BadRequest: return(BadRequest); case ErrorTypeEnum.Forbidden: return(Forbidden); case ErrorTypeEnum.NotImplemented: return(NotImplemented); case ErrorTypeEnum.Frozen: return(Frozen); case ErrorTypeEnum.NotAcceptable: return(NotAcceptable); case ErrorTypeEnum.Gone: return(Gone); case ErrorTypeEnum.Moved: return(Moved); case ErrorTypeEnum.HasBeenUpdated: return(HasBeenUpdated); case ErrorTypeEnum.InternalServerError: return(InternalServerError); default: throw new ArgumentException(String.Format("Unknown error type: \"{0}\".", errorType)); } }
public RequestWarningException(ErrorTypeEnum errorTypeProp, string message) : base(message) { ErrorTypeProp = errorTypeProp; ExceptionMessageProp = message; }
public RepositoryException(string message, ErrorTypeEnum errType, Exception inner, int errorCode) : base(message, inner) { this.ErrorCode = errorCode; this.ErrorType = errType; }
/// <summary> /// The constructor. /// </summary> /// <param name="request">The request that this is a response to.</param> /// <param name="errorType">The error type.</param> public FailureResponse(Request request, ErrorTypeEnum errorType) : base(request, ResponseTypeEnum.Failure) { ErrorTypeAsString = TranslateErrorType(errorType); }
public static Exception ReThrow <T>(Exception ex) { SqlException sqlEx = TryExtractException <SqlException>(ex); DbUpdateException dbEx = TryExtractException <DbUpdateException>(ex); if (sqlEx != null) { //string exMessage = sqlEx.Message; string message = RepositoryResource.ErrorMessage_GeneralError; ErrorTypeEnum error = ErrorTypeEnum.None; string columnName = string.Empty; string tableName = string.Empty; string indexName = string.Empty; MatchCollection coll; switch (sqlEx.Number) { case (2): case (53): //_error = DataAccessErrorType.NetworkAddressNotFound; break; case (547): //if (sqlEx.Message.Contains("DELETE")) //{ // Match match = Regex.Match(sqlEx.Message, @"\'([^']*)\'"); // coll = Regex.Matches(sqlEx.Message, "\"[^\"]*\""); // //if (match.Success) // // columnName = match.Value.Substring(1, match.Value.Length - 2); // if (coll.Count == 3) // tableName = coll[2].Value.Substring(1, coll[2].Value.Length - 2); //} //error = ErrorTypeEnum.DeleteReferencedRecord; //string tableNameCaption = ResourceManager.GetString(tableName.Replace('.', '_')); //string entityNameCaption = typeof(T).Name; //if (string.IsNullOrEmpty(tableNameCaption) || string.IsNullOrEmpty(entityNameCaption)) // message = RepositoryResource.ErrorMessage_GeneralDependency; //else // message = string.Format(RepositoryResource.ErrorMessage_TwoEntityDependency, tableNameCaption, entityNameCaption); return(new BusinessRuleException(RepositoryResource.ErrorMessage_GeneralDependency, RepositoryResource.ErrorMessage_GeneralDependency, typeof(T).Name, sqlEx)); case (4060): //error = ErrorTypeEnum.InvalidDatabase; break; case (18452): case (18456): error = ErrorTypeEnum.LoginFailed; message = RepositoryResource.ErrorMessage_LogingFailed; break; case (10054): //_error = DataAccessErrorType.ConnectionRefused; break; case (2627): case (2601): error = ErrorTypeEnum.DuplicateValue; message = "يجب أن لا يتكرر الحقل الفريد"; break; default: break; } if (sqlEx.Class == 20) { error = ErrorTypeEnum.ConnectionFailed; message = RepositoryResource.ErrorMessage_ConnectionFailed; } return(new RepositoryException(typeof(T).Name, error, message, ex)); } else if (ex is InvalidOperationException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.None, ex.Message, ex)); } else if (ex is DbUpdateConcurrencyException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.ConcurrencyCheckFailed, "تم تعديل الكائن من قبل مستخدم آخر, يرجى تحديث المستعرض والمحاولة مرة آخرى", ex)); } else if (ex is ModelValidationException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.ValidationError, "يجب التأكد من أن قواعد التأكد من الصحة صحيحة", ex)); } return(ex); }
protected OkObjectResult Failure(ErrorTypeEnum errorType, object error) => Ok(new ResponseData <object>(errorType, error));
/// <summary> /// 构造函数 /// </summary> /// <param name="type"></param> /// <param name="data"></param> public Response(ErrorTypeEnum type, T data) { Type = type; Data = data; }
public static Exception ReThrow <T>(Exception ex) { SqlException sqlEx = TryExtractException <SqlException>(ex); DbUpdateException dbEx = TryExtractException <DbUpdateException>(ex); //string entityNames = string.Join(", ", dbEx.Entries.Select(x => GetEntityName(x.Entity))); if (sqlEx != null) { string exMessage = sqlEx.Message; string message = string.Empty; ErrorTypeEnum error = ErrorTypeEnum.None; string columnName = string.Empty; string tableName = string.Empty; string indexName = string.Empty; MatchCollection coll; switch (sqlEx.Number) { case (2): case (53): //_error = DataAccessErrorType.NetworkAddressNotFound; break; case (547): if (exMessage.Contains("DELETE")) { Match match = Regex.Match(exMessage, @"\'([^']*)\'"); coll = Regex.Matches(exMessage, "\"[^\"]*\""); if (match.Success) { columnName = match.Value.Substring(1, match.Value.Length - 2); } if (coll.Count == 3) { tableName = coll[2].Value.Substring(1, coll[2].Value.Length - 2); } } error = ErrorTypeEnum.DeleteReferencedRecord; string tableNameCaption = tableName; string entityNameCaption = typeof(T).Name; if (string.IsNullOrEmpty(tableNameCaption) || string.IsNullOrEmpty(entityNameCaption)) { message = "Can not delete this element because some element is related to it."; } else { message = string.Format("Can not delete because {0} is depending on {1} , which you are deleting.", tableNameCaption, entityNameCaption); } return(new BusinessRuleException(message, "Master Entity Deletion With Slave Entities", typeof(T).Name, sqlEx)); case (4060): //_error = DataAccessErrorType.InvalidDatabase; break; case (18452): case (18456): error = ErrorTypeEnum.LoginFailed; message = "خطأ في المصادقة مع مخدم قواعد البيانات"; break; case (10054): //_error = DataAccessErrorType.ConnectionRefused; break; case (2627): case (2601): error = ErrorTypeEnum.DuplicateValue; message = "يجب أن لا يتكرر الحقل الفريد"; break; default: break; } if (sqlEx.Class == 20) { error = ErrorTypeEnum.ConnectionFailed; message = "اسم مخدم قاعدة البيانات غير صحيح أو لا يمكن الوصول إليه"; } return(new RepositoryException(typeof(T).Name, error, message, ex)); } else if (ex is InvalidOperationException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.None, ex.Message, ex)); } else if (ex is DbUpdateConcurrencyException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.ConcurrencyCheckFailed, "تم تعديل الكائن من قبل مستخدم آخر, يرجى تحديث المستعرض والمحاولة مرة آخرى", ex)); } else if (ex is ModelValidationException) { return(new RepositoryException(typeof(T).Name, ErrorTypeEnum.ValidationError, "يجب التأكد من أن قواعد التأكد من الصحة صحيحة", ex)); } return(null); }
/// <summary> /// Initializes a new instance of the <see cref="RepositoryException"/> class with specified business entity name, error type, error message, and a reference to the inner exception that is the cause of this exception. /// </summary> /// <param name="entityName">business entity name that being persisted or retrieved.</param> /// <param name="errorType">generic classification of errors.</param> /// <param name="message">custom message that describes the error.</param> /// <param name="inner">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param> public RepositoryException(string entityName, ErrorTypeEnum errorType, string message, Exception inner) : base(message, inner) { this.EntityName = entityName; this.ErrorType = errorType; }
/// <summary> /// Initializes a new instance of the <see cref="RepositoryException"/> class with specified business entity name, and error type. /// </summary> /// <param name="entityName">business entity name that being persisted or retrieved.</param> /// <param name="errorType">generic classification of errors.</param> public RepositoryException(string entityName, ErrorTypeEnum errorType) : base(string.Format("Error [{0}] has been occurred while retrieving or persisting [{1}] entity.", entityName, errorType)) { this.EntityName = entityName; this.ErrorType = errorType; }
public PSErrorHelperObject(ErrorTypeEnum ete) { this.ErrorType = ete; }
public ResponseData(ErrorTypeEnum errorType, object error) : this(errorType) { Error.Data = error; }
public KnownException(ErrorTypeEnum errorType, string message) : base(message) { ErrorTypeProp = errorType; ExceptionMessageProp = message; }