Esempio n. 1
0
        public void CaptureError(string message, string culprit, StackFrame[] frames)
        {
            var capturedException = new CapturedException
            {
                Message = message
            };
            var error = new Error.ErrorDetail
            {
                Culprit     = culprit,
                Exception   = capturedException,
                Transaction = new Error.ErrorDetail.TransactionReference
                {
                    Id = Id
                }
            };

            if (frames != null)
            {
                capturedException.StacktTrace
                    = StacktraceHelper.GenerateApmStackTrace(frames, _logger, "failed capturing stacktrace");
            }

            error.Context = Context;
            _sender.QueueError(new Error {
                Errors = new List <IErrorDetail> {
                    error
                }, Service = Service
            });
        }
Esempio n. 2
0
        public void CaptureException(Exception exception, string culprit = null, bool isHandled = false)
        {
            var capturedCulprit = string.IsNullOrEmpty(culprit) ? "PublicAPI-CaptureException" : culprit;

            var capturedException = new CapturedException
            {
                Message = exception.Message,
                Type    = exception.GetType().FullName,
                Handled = isHandled
            };

            var error = new Error.ErrorDetail
            {
                Culprit     = capturedCulprit,
                Exception   = capturedException,
                Transaction = new Error.ErrorDetail.TransactionReference
                {
                    Id = Id
                }
            };

            if (!string.IsNullOrEmpty(exception.StackTrace))
            {
                capturedException.StacktTrace
                    = StacktraceHelper.GenerateApmStackTrace(new StackTrace(exception, true).GetFrames(), _logger,
                                                             "failed capturing stacktrace");
            }

            error.Context = Context;
            _sender.QueueError(new Error {
                Errors = new List <IErrorDetail> {
                    error
                }, Service = Service
            });
        }