package com.skraylabs.poker.model;

/**
 * A checked exception thrown when a string cannot be resolved to the expected {@link Card} format.
 */
public class CardFormatException extends Exception {
  /**
   * Generated serial ID.
   */
  private static final long serialVersionUID = -1704270302225109151L;

  /**
   * Default detail message used when the invalid string sample is not provided.
   */
  public static final String MSG_DEFAULT =
      "The provided string could not be resolved to a Card format.";

  /**
   * Detail message used when the invalid string sample is provided. Expects one String argument.
   */
  public static final String MSG_WITH_INVALID_STRING =
      "The string <\"%s\"> could not be resolved to a Card format.";

  /**
   * Invalid string representation of a {@link Card}.
   */
  private String invalidString;

  /**
   * Default constructor.
   */
  public CardFormatException() {
    super(MSG_DEFAULT);
  }

  /**
   * Constructor.
   *
   * @param invalidString offending string
   */
  public CardFormatException(String invalidString) {
    // Use 1 of 2 message formats depending on whether or not invalidString argument is empty/null.
    super((invalidString == null) ? MSG_DEFAULT
        : String.format(MSG_WITH_INVALID_STRING, invalidString));
    if (invalidString != null) {
      this.invalidString = invalidString;
    }
  }

  /**
   * Accessor: string with invalid format.
   *
   * @return the invalidString
   */
  public String getInvalidString() {
    return invalidString;
  }
}

@@ -1078,65 +1078,209 @@
     
-// Use 1 of 2 message formats depending on wh
+super(formatMessageForInvalidString(invalidString));%0A    if (invalidString != null) %7B%0A      this.invalidString = invalidString;%0A    %7D%0A  %7D%0A%0A  /**%0A   * Helper method to d
 et
-h
 er
- or not
+mine message based on a given
  inv
@@ -1294,205 +1294,916 @@
 ing 
+p
 ar
-gument is empty/null.%0A    super((invalidString == null) ? MSG_DEFAULT%0A        : String.format(MSG_WITH_INVALID_STRING, invalidString));%0A    if (invalidString != null) %7B%0A      this.invalidString =
+ameter.%0A   *%0A   * %3Cp%3E%0A   * This is mainly intended to be used by the initializing constructor%0A   * %7B@link CardFormatException#CardFormatException(String)%7D.%0A   *%0A   * %3Cp%3E%0A   * Although %7B@code invalidString%7D is expected to be non-null, it would be undesirable for the%0A   * constructor to throw an IllegalArgumenException. Instead, this helper method will test for null%0A   * and return the default exception message. Otherwise, this helper method will insert the%0A   * %7B@code invalidString%7D value into the %7B@link CardFormatException#MSG_WITH_INVALID_STRING%7D%0A   * format.%0A   *%0A   * @param invalidString offending string (which may erroneously be set to null)%0A   * @return an appropriate exception message%0A   */%0A  protected static String formatMessageForInvalidString(String invalidString) %7B%0A    String result = MSG_DEFAULT;%0A    if (invalidString != null) %7B%0A      result = String.format(MSG_WITH_INVALID_STRING,
  inv
@@ -2208,32 +2208,33 @@
 nvalidString
+)
 ;%0A    %7D%0A
   %7D%0A%0A  /**%0A 
@@ -2213,32 +2213,51 @@
 dString);%0A    %7D%0A
+    return result;%0A
   %7D%0A%0A  /**%0A   * 

define helper method for constructor.