/// <summary> /// Creates a <see cref="AirbrakeError"/> from the the specified exception. /// </summary> /// <param name="exception">The exception.</param> /// <param name="component">component where the error occured, extracted from stack trace</param> /// <returns> /// A <see cref="AirbrakeError"/>, created from the the specified exception. /// </returns> public AirbrakeError ErrorFromException(Exception exception, out string component) { if (exception == null) throw new ArgumentNullException("exception"); "{0}.Notice({1})\r\n{2}".TraceDebug(GetType(), exception.GetType(), exception); var error = new AirbrakeError { Class = exception.GetType().FullName, Message = exception.GetType().Name + ": " + exception.Message, Backtrace = BuildBacktrace(exception, out component).ToArray(), }; return error; }
/// <summary> /// Creates a <see cref="AirbrakeNotice"/> from the the specified error. /// </summary> /// <param name="error">The error.</param> /// <param name="extraParams"> Extra data for logging in params </param> /// <param name="component">Component where the error occured</param> /// <returns></returns> public AirbrakeNotice Notice(AirbrakeError error, IEnumerable<KeyValuePair<string,string>> extraParams = null, string component = null) { "{0}.Notice({1})\r\n{2}".TraceDebug(GetType(), component, error); var notice = new AirbrakeNotice { ApiKey = Configuration.ApiKey, Error = error, Notifier = Notifier, ServerEnvironment = ServerEnvironment, }; if (HttpContext.Current != null) { var context = new HttpContextWrapper(HttpContext.Current); string action = null; notice.Request = new AirbrakeRequest(context.Request.Url, component ?? Assembly.GetEntryAssembly().CodeBase) { Params = BuildParams(context.Request, extraParams).ToArray(), Session = BuildSession(context.Session).ToArray(), CgiData = BuildCgiData(context.Request).ToArray(), }; } return notice; }