Exemplo n.º 1
0
        public void AfterThrowing(MethodInfo method, Object[] args, Object target, Exception exception)//where T : ASAException
        {
            ASAException tempException;

            if (exception is ASAException)
            {
                tempException = (ASAException)exception;
                if (tempException.ExceptionError_id == null)
                {
                    //set ExceptionError_id if not already set
                    tempException.ExceptionError_id = "GEN0000001";
                }
            }
            else
            {
                try
                {
                    ASAExceptionTranslator afterThrowingTranslator = new ASAExceptionTranslator();
                    tempException = afterThrowingTranslator.Translate(exception);
                }
                catch (ASAException e)
                {
                    tempException = e;
                }
            }

            if (Logger.IsInfoEnabled)
            {
                GlobalContext.Properties["stack"] = Environment.StackTrace;
                Logger.Info(exception.Source + exception.GetType().ToString());
            }

            tempException.Error_call_stack = exception.StackTrace + "/////////" + Environment.StackTrace;

            throw tempException;
        }
Exemplo n.º 2
0
        // Provide a fault. The Message fault parameter can be replaced, or set to
        // null to suppress reporting a fault.
        public void ProvideFault(Exception error, MessageVersion version, ref Message msg)
        {
            _mSELDao = (ISELDao)ContextHelper.GetContextObject("SELDAO");

            ASAException translatedException = new ASAException();

            //catch all, in case error comes into EHF without being translated
            if (error is ASAException)
            {
                translatedException = (ASAException)error;
            }
            else
            {
                ASAExceptionTranslator afterThrowingTranslator = new ASAExceptionTranslator();
                translatedException = afterThrowingTranslator.Translate(error);
            }

            string tidCorrelationID = ASATIDHelper.GetTIDCorrelationID();

            if (error != null && error is NoMatchingObjectException)
            {
                msg = BuildErrorMessage <ASAFaultDetail>(version, "Server", tidCorrelationID, translatedException.Error_FaultString, translatedException.Error_DetailMessage);
            }
            else if (error != null && error is ServiceRequestValidationException)
            {
                msg = BuildErrorMessage <ASAFaultDetail>(version, "Server", tidCorrelationID, translatedException.Error_FaultString + ": " + translatedException.Error_DetailMessage, translatedException.Error_DetailMessage);
            }
            else if (error != null && error is ServiceReplyValidationException)
            {
                msg = BuildErrorMessage <ASAFaultDetail>(version, "Server", tidCorrelationID, translatedException.Error_FaultString, translatedException.Error_DetailMessage);
            }
            else if (error != null && error is ASADemogBusinessException)
            {
                //QC 1690-1693 handle new exception types
                msg = BuildErrorMessage <ASADemogFaultDetail>(version, "Server", tidCorrelationID, translatedException.Error_FaultString + ": " + translatedException.Error_DetailMessage, translatedException.Error_DetailMessage);
            }
            else if (error != null && error is ASABusinessException)
            {
                //QC 1690-1693 handle new exception types
                msg = BuildErrorMessage <ASABusinessFaultDetail>(version, "Server", tidCorrelationID, translatedException.Error_FaultString + ": " + translatedException.Error_DetailMessage, translatedException.Error_DetailMessage);
            }
            else if (error != null && error is Exception)
            {
                switch (translatedException.ExceptionType)
                {
                case "ASADataAccessException":
                case "ASAUnknownException":
                case "ASA.ExcErrCodeUnavail":
                {
                    msg = BuildErrorMessage <ASAFaultDetail>(version, "Server", tidCorrelationID,
                                                             translatedException.BusinessDescription, translatedException.Original_Message);
                    break;
                }

                default:
                {
                    msg = BuildErrorMessage <ASAFaultDetail>(version, "Server", tidCorrelationID,
                                                             translatedException.Error_FaultString, translatedException.Error_DetailMessage);
                    break;
                }
                }
            }

            Log.Error(msg);

            #region add message to the LogException tables

            string payload = string.Empty;

            if (Payload.ContainsMessagePayLoad(tidCorrelationID))
            {
                payload = Payload.GetMessagePayLoad(tidCorrelationID);
            }

            //LogEvent logEventRec = new LogEvent();
            LogException logExceptionRec = new LogException();

            logExceptionRec.CreatedBy        = (ASATIDHelper.GetTIDUsername() != "") ? ASATIDHelper.GetTIDUsername() : "ASA_USER";
            logExceptionRec.CreatedDate      = DateTime.Now;
            logExceptionRec.Payload          = payload.ToString();
            logExceptionRec.ExceptionStack   = error.StackTrace;
            logExceptionRec.Correlationid    = new Guid(tidCorrelationID);
            logExceptionRec.ExceptionErrorid = translatedException.ExceptionError_id;

            long eventID;

            try
            {
                //_mSELDao.AddLogExceptionRecord(logExceptionRec, out eventID);
                Log.Error(payload);
                Log.Error(logExceptionRec);
            }

            catch (Exception ex)
            {
                //if there is an error logging the record to the DB, write payload to log file
                Log.Error(payload);
            }
            #endregion
        }