Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(expectedExceptions = IllegalArgumentException.class) public void createByBuilder_bothValueAndFailure()
        public virtual void createByBuilder_bothValueAndFailure()
        {
            Result.meta().builder().set("value", "A").set("failure", Failure.of(CALCULATION_FAILED, "Fail")).build();
        }
Exemplo n.º 2
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)));
 }
Exemplo n.º 3
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)));
        }
Exemplo n.º 4
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)));
 }