Ejemplo n.º 1
0
		public ExceptionDetail (Exception exception)
		{
			if (exception == null)
				throw new ArgumentNullException ("exception");
			Message = exception.Message;
			StackTrace = exception.StackTrace;
			Type = exception.GetType ().FullName;
			if (exception.InnerException != null)
				InnerException = new ExceptionDetail (exception.InnerException);
		}
Ejemplo n.º 2
0
 private string GetDetailExceptionMessageRecursive(System.ServiceModel.ExceptionDetail iException)
 {
     if (iException.InnerException != null)
     {
         return(GetDetailExceptionMessageRecursive(iException.InnerException));
     }
     else
     {
         return(iException.Message);
     }
 }
Ejemplo n.º 3
0
        public override void Run()
        {
            try
            {
                Logging.LogInfo("Import job being run on file " + _contentFileName);
                StoreWorker.TransactionLog.LogStartTransaction(this);

                var parser = GetParser(_contentFileName);
                var storeDirectory = StoreWorker.WriteStore.DirectoryPath;
                var filePath = Path.Combine(storeDirectory,
                                            ".." + Path.DirectorySeparatorChar + "import" + Path.DirectorySeparatorChar +
                                            _contentFileName);
                var profiler = new BrightstarProfiler("Import " + _contentFileName); // TODO : Conditionally create this if profiling is enabled
                Logging.LogDebug("Import file path calculated as '{0}'", filePath);
                if (!File.Exists(filePath))
                {
                    ErrorMessage = String.Format("Cannot find file {0} in import directory", _contentFileName);
                    throw new FileNotFoundException(ErrorMessage);
                }
                using (_fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                {
                    _importTripleSink = new StoreTripleSink(StoreWorker.WriteStore, JobId,
                                                            Configuration.TransactionFlushTripleCount,
                                                            profiler:profiler);
                    parser.Parse(_fileStream, this, _graphUri);
                }
                StoreWorker.WriteStore.Commit(JobId, profiler);
                StoreWorker.InvalidateReadStore();

                Logging.LogInfo("Import job completed successfully for " + _contentFileName);
                if (profiler != null)
                {
                    Logging.LogInfo(profiler.GetLogString());
                }
                StoreWorker.TransactionLog.LogEndSuccessfulTransaction(this);
            }
            catch (RdfParserException parserException)
            {
                ErrorMessage = parserException.Message;
                ExceptionDetail = new ExceptionDetail(parserException);
                Logging.LogInfo("Parser error processing import job on file " + _contentFileName + ". " + parserException.Message);
                throw;
            }
            catch (Exception ex)
            {
                ErrorMessage = "Error importing file " + _contentFileName + ". " + ex.Message;
                StoreWorker.TransactionLog.LogEndFailedTransaction(this);
                Logging.LogInfo("Error processing import job on file " + _contentFileName + ". Error Message: " + ex.Message + " Stack trace: " + ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 4
0
 public ExceptionDetail(Exception exception)
 {
     if (exception == null)
     {
         throw new ArgumentNullException("exception");
     }
     Message    = exception.Message;
     StackTrace = exception.StackTrace;
     Type       = exception.GetType().FullName;
     if (exception.InnerException != null)
     {
         InnerException = new ExceptionDetail(exception.InnerException);
     }
 }
 public ExceptionDetail(Exception exception)
 {
     if (exception == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exception");
     }
     this.helpLink = exception.HelpLink;
     this.message = exception.Message;
     this.stackTrace = exception.StackTrace;
     this.type = exception.GetType().ToString();
     if (exception.InnerException != null)
     {
         this.innerException = new ExceptionDetail(exception.InnerException);
     }
 }
 public ExceptionDetail(Exception exception)
 {
     if (exception == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exception");
     }
     this.helpLink   = exception.HelpLink;
     this.message    = exception.Message;
     this.stackTrace = exception.StackTrace;
     this.type       = exception.GetType().ToString();
     if (exception.InnerException != null)
     {
         this.innerException = new ExceptionDetail(exception.InnerException);
     }
 }
        public override Exception HandlerException(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Exception exception)
        {
            //if (exception is GenericException)
            //    exception = exception;

            if (exception is WebFaultException<ExceptionDetail>)
                throw exception;

            if (!(exception is GenericException))
                exception = new GenericException(exception);

            ExceptionDetail detail = new ExceptionDetail(exception);

            var result = new WebFaultException<ExceptionDetail>(detail, HttpStatusCode.BadRequest);
            throw result;
        }
Ejemplo n.º 8
0
        private static void GetExceptionText(ExceptionDetail exception, StringBuilder stringBuilder)
        {
            Debug.Assert(exception != null);
            Debug.Assert(stringBuilder != null);

            stringBuilder.AppendLine();
            stringBuilder.AppendLine(exception.Type);
            stringBuilder.AppendLine(exception.Message);
            stringBuilder.AppendLine(exception.StackTrace);

            if (exception.InnerException != null)
            {
                stringBuilder.AppendLine("------------");
                GetExceptionText(exception.InnerException, stringBuilder);
            }
        }
Ejemplo n.º 9
0
        public override void Run()
        {
            try
            {
                Logging.LogInfo("Import job being run on file " + _contentFileName);
                StoreWorker.TransactionLog.LogStartTransaction(this);

                var parser = GetParser(_contentFileName);
                var storeDirectory = StoreWorker.WriteStore.DirectoryPath;
                var importDirectory = Path.Combine(Path.GetDirectoryName(storeDirectory), "import");
                var filePath = Path.Combine(importDirectory, _contentFileName);
                var profiler = Logging.IsProfilingEnabled ? new BrightstarProfiler("Import " + _contentFileName) : null;
                Logging.LogDebug("Import file path calculated as '{0}'", filePath);

                using (_fileStream = GetImportFileStream(filePath))
                {
                    _importTripleSink = new StoreTripleSink(StoreWorker.WriteStore, JobId,
                                                            Configuration.TransactionFlushTripleCount,
                                                            profiler:profiler);
                    parser.Parse(_fileStream, this, _graphUri);
                }
                StoreWorker.WriteStore.Commit(JobId, profiler);
                StoreWorker.InvalidateReadStore();

                Logging.LogInfo("Import job completed successfully for " + _contentFileName);
                if (profiler != null)
                {
                    Logging.LogInfo(profiler.GetLogString());
                }
                StoreWorker.TransactionLog.LogEndSuccessfulTransaction(this);
            }
            catch (RdfParserException parserException)
            {
                ErrorMessage = parserException.Message;
                ExceptionDetail = new ExceptionDetail(parserException);
                Logging.LogInfo("Parser error processing import job on file " + _contentFileName + ". " + parserException.Message);
                throw;
            }
            catch (Exception ex)
            {
                ErrorMessage = "Error importing file " + _contentFileName + ". " + ex.Message;
                StoreWorker.TransactionLog.LogEndFailedTransaction(this);
                Logging.LogInfo("Error processing import job on file " + _contentFileName + ". Error Message: " + ex.Message + " Stack trace: " + ex.StackTrace);
                throw;
            }
        }
Ejemplo n.º 10
0
        public ExceptionDetail(Exception exception)
        {
            if (exception == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exception");
            }

            _helpLink = exception.HelpLink;
            _message = exception.Message;
            _stackTrace = exception.StackTrace;
            _type = exception.GetType().ToString();

            if (exception.InnerException != null)
            {
                _innerException = new ExceptionDetail(exception.InnerException);
            }
        }
Ejemplo n.º 11
0
        public ExceptionDetail(Exception exception)
        {
            if (exception == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("exception");
            }

            _helpLink   = exception.HelpLink;
            _message    = exception.Message;
            _stackTrace = exception.StackTrace;
            _type       = exception.GetType().ToString();

            if (exception.InnerException != null)
            {
                _innerException = new ExceptionDetail(exception.InnerException);
            }
        }
Ejemplo n.º 12
0
        void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            try
            {
                // Add code here to build faultreason for client based on exception
                FaultReason faultReason = new FaultReason(error.Message);
                ExceptionDetail exceptionDetail = new ExceptionDetail(error);

                // For security reasons you can also decide to not give the ExceptionDetail back to the client or change the message, etc
                FaultException<ExceptionDetail> faultException = new FaultException<ExceptionDetail>(exceptionDetail, faultReason, FaultCode.CreateSenderFaultCode(new FaultCode("0")));

                MessageFault messageFault = faultException.CreateMessageFault();
                fault = Message.CreateMessage(version, messageFault, faultException.Action);
            }
            catch
            {
                // Todo log error
            }
        }
        public override Exception HandlerException(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Exception exception)
        {
            if (exception is WebFaultException<ExceptionDetail>)
            {

                string note = FormmatException(exception.StackTrace,exception.Message);
                ExceptionLog.Write(note);
                throw exception;
            }
            if (!(exception is GenericException))
            {
                exception = new GenericException(exception);
                string notepad = FormmatException(exception.StackTrace, exception.Message);
                ExceptionLog.Write(notepad);
            }
            ExceptionDetail detail = new ExceptionDetail(exception);

            var result = new WebFaultException<ExceptionDetail>(detail, HttpStatusCode.BadRequest);

            throw result;
        }
		Message CreateSimpleFaultMessage (Exception error, MessageVersion version)
		{
			OperationContext ctx = OperationContext.Current;
			// FIXME: support more fault code depending on the exception type.
			FaultCode fc = null;
			if (error is EndpointNotFoundException)
				fc = new FaultCode (
					"DestinationUnreachable",
					version.Addressing.Namespace);
			else
				fc = new FaultCode (
					"FIXME_InternalError",
					version.Addressing.Namespace);

#if !NET_2_1
			// FIXME: set correct fault reason.
			if (ctx.EndpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults) {
				ExceptionDetail detail = new ExceptionDetail (error);
				return Message.CreateMessage (version, fc,
					"error occured", detail, ctx.IncomingMessageHeaders != null ? ctx.IncomingMessageHeaders.Action : null);
			}
#endif
			return Message.CreateMessage (version, fc, "error occured", ctx.IncomingMessageHeaders.Action);
		}
Ejemplo n.º 15
0
 private static void ExtractSyntaxError(ExceptionDetail exceptionDetail)
 {
     if (exceptionDetail == null) return;
     if (exceptionDetail.Type.Equals("VDS.RDF.Parsing.RdfParseException"))
     {
         throw new RdfParseException(exceptionDetail.Message);
     }
     ExtractSyntaxError(exceptionDetail.InnerException);
 }
 internal BrightstarClientException(string message, Exception inner) : base(message, inner)
 {
     InnerException = new ExceptionDetail(inner);
 }
 internal BrightstarClientException(string message, RdfParserException parserException) : base(
     parserException.HaveLineNumber ?String.Format( "{0} Line {1}: {2}", message, parserException.LineNumber, parserException.Message):
     String.Format("{0} {1}", message, parserException.Message), parserException)
 {
     InnerException = new ExceptionDetail(parserException);
 }
 internal BrightstarClientException(string message, ExceptionDetail detail) : base(message)
 {
     InnerException = detail;
 }
 internal BrightstarClientException(FaultException<ExceptionDetail> fault) 
     : base(fault.Detail!=null && fault.Detail.Message != null ? fault.Detail.Message : DefaultServiceErrorMessage)
 {
     InnerException = fault.Detail == null ? null : fault.Detail.InnerException;
 }
        public void ShouldNotCreateOpportunityResponse()
        {
            const int opportunityId = 10000000;
            const string comment = "Fail Test Comment";
            const int mockParticipantId = 7777;
            _participantService.Setup(m => m.GetParticipantRecord(It.IsAny<string>()))
                .Returns(new Participant {ParticipantId = mockParticipantId});

            const string opportunityResponsePageKey = "OpportunityResponses";
            var exceptionDetail =
                new ExceptionDetail(new Exception("The creator of this fault did not specify a Reason."));
            var faultException = new FaultException<ExceptionDetail>(exceptionDetail);

            _ministryPlatformService.Setup(
                m =>
                    m.CreateRecord(opportunityResponsePageKey,
                                   It.IsAny<Dictionary<string, object>>(),
                                   It.IsAny<string>(),
                                   true))
                .Throws(faultException);

            Assert.Throws<FaultException<ExceptionDetail>>(
                () => _fixture.RespondToOpportunity(It.IsAny<string>(), opportunityId, comment));

            _participantService.Verify(m => m.GetParticipantRecord(It.IsAny<string>()), Times.Once);
            _ministryPlatformService.VerifyAll();
        }
Ejemplo n.º 21
0
 void ProvideWellKnownFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     Message faultMessage;
     if (faultConverter != null && faultConverter.TryCreateFaultMessage(e, out faultMessage))
     {
         faultInfo.Fault = faultMessage;
         return;
     }
     else if (e is NetDispatcherFaultException)
     {
         NetDispatcherFaultException ndfe = e as NetDispatcherFaultException;
         if (this.debug)
         {
             ExceptionDetail detail = new ExceptionDetail(ndfe);
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, MessageFault.CreateFault(ndfe.Code, ndfe.Reason, detail), ndfe.Action);
         }
         else
         {
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, ndfe.CreateMessageFault(), ndfe.Action);
         }
     }
 }
Ejemplo n.º 22
0
		protected override bool OnTryCreateFaultMessage (Exception error, out Message message)
		{
			if (version.Envelope.Equals (EnvelopeVersion.None)) {
				message = null;
				return false;
			}

			string action;
			if (!map.TryGetValue (error.GetType (), out action)) {
				message = null;
				return false;
			}

			FaultCode fc;
			if (version.Envelope.Equals (EnvelopeVersion.Soap12))
				fc = new FaultCode ("Sender", version.Envelope.Namespace, new FaultCode (action, version.Addressing.Namespace));
			else
				fc = new FaultCode (action, version.Addressing.Namespace);

			OperationContext ctx = OperationContext.Current;
			// FIXME: support more fault code depending on the exception type.
#if !NET_2_1 && !XAMMAC_4_5
			// FIXME: set correct fault reason.
			if (ctx != null && ctx.EndpointDispatcher.ChannelDispatcher.IncludeExceptionDetailInFaults) {
				ExceptionDetail detail = new ExceptionDetail (error);
				message = Message.CreateMessage (version, fc,
					error.Message, detail, version.Addressing.FaultNamespace);
			}
			else
#endif
				message = Message.CreateMessage (version, fc, error.Message, version.Addressing.FaultNamespace);

			return true;
		}
Ejemplo n.º 23
0
 public SparqlUpdateException(ExceptionDetail innerDetail)
     : base("An error occurred while executing the SPARQL update: " + innerDetail.Message) { }
 private void ProvideWellKnownFault(Exception e, FaultConverter faultConverter, ref ErrorHandlerFaultInfo faultInfo)
 {
     Message message;
     if ((faultConverter != null) && faultConverter.TryCreateFaultMessage(e, out message))
     {
         faultInfo.Fault = message;
     }
     else if (e is NetDispatcherFaultException)
     {
         NetDispatcherFaultException exception = e as NetDispatcherFaultException;
         if (this.debug)
         {
             ExceptionDetail detail = new ExceptionDetail(exception);
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, MessageFault.CreateFault(exception.Code, exception.Reason, detail), exception.Action);
         }
         else
         {
             faultInfo.Fault = Message.CreateMessage(this.messageVersion, exception.CreateMessageFault(), exception.Action);
         }
     }
 }