コード例 #1
0
 /// <summary>
 /// Obtains a failure from a reason and exception.
 /// </summary>
 /// <param name="reason">  the reason </param>
 /// <param name="cause">  the cause </param>
 /// <returns> the failure </returns>
 public static Failure of(FailureReason reason, Exception cause)
 {
     return(Failure.of(FailureItem.of(reason, cause)));
 }
コード例 #2
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Obtains a failure from a reason and message.
        /// <para>
        /// The message is produced using a template that contains zero to many "{}" placeholders.
        /// Each placeholder is replaced by the next available argument.
        /// If there are too few arguments, then the message will be left with placeholders.
        /// If there are too many arguments, then the excess arguments are appended to the
        /// end of the message. No attempt is made to format the arguments.
        /// See <seealso cref="Messages#format(String, Object...)"/> for more details.
        /// </para>
        /// <para>
        /// An exception will be created internally to obtain a stack trace.
        /// The cause type will not be present in the resulting failure.
        ///
        /// </para>
        /// </summary>
        /// <param name="reason">  the reason </param>
        /// <param name="message">  a message explaining the failure, not empty, uses "{}" for inserting {@code messageArgs} </param>
        /// <param name="messageArgs">  the arguments for the message </param>
        /// <returns> the failure </returns>
        public static Failure of(FailureReason reason, string message, params object[] messageArgs)
        {
            string msg = Messages.format(message, messageArgs);

            return(Failure.of(FailureItem.of(reason, msg, 1)));
        }
コード例 #3
0
 /// <summary>
 /// Obtains a failure from a reason, message and exception.
 /// <para>
 /// The message is produced using a template that contains zero to many "{}" placeholders.
 /// Each placeholder is replaced by the next available argument.
 /// If there are too few arguments, then the message will be left with placeholders.
 /// If there are too many arguments, then the excess arguments are appended to the
 /// end of the message. No attempt is made to format the arguments.
 /// See <seealso cref="Messages#format(String, Object...)"/> for more details.
 ///
 /// </para>
 /// </summary>
 /// <param name="reason">  the reason </param>
 /// <param name="cause">  the cause </param>
 /// <param name="message">  the failure message, possibly containing placeholders, formatted using <seealso cref="Messages#format"/> </param>
 /// <param name="messageArgs">  arguments used to create the failure message </param>
 /// <returns> the failure </returns>
 public static Failure of(FailureReason reason, Exception cause, string message, params object[] messageArgs)
 {
     return(Failure.of(FailureItem.of(reason, cause, message, messageArgs)));
 }