Пример #1
0
        /// <summary>
        /// Packages as payload body.
        /// </summary>
        /// <param name="bodyObject">The body object.</param>
        /// <param name="custom">The custom.</param>
        /// <returns>Body.</returns>
        public static Body PackageAsPayloadBody(object bodyObject, ref IDictionary <string, object?>?custom)
        {
            System.Exception?exception = bodyObject as System.Exception;
            if (exception != null)
            {
                RollbarUtility.SnapExceptionDataAsCustomData(exception, ref custom);
                return(new Body(exception));
            }

            string?messageString = bodyObject as string;

            if (messageString != null)
            {
                return(new Body(new Message(messageString)));
            }

            ITraceable?traceable = bodyObject as ITraceable;

            if (traceable != null)
            {
                return(new Body(traceable.TraceAsString()));
            }

            return(new Body(new Message(bodyObject.ToString())));
        }