All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.geotab.http.exception.DuplicateException Maven / Gradle / Ivy

/*
 *
 * 2020 Copyright (C) Geotab Inc. All rights reserved.
 */

package com.geotab.http.exception;

import org.apache.commons.lang3.StringUtils;

/**
 * An exception that occurs when adding a new object or when updating an existing object that would
 * cause a duplicate entry to occur.
 */
public class DuplicateException extends JsonRpcErrorDataException {


  /**
   * The default constructor.
   */
  public DuplicateException() {
  }

  /**
   * Initializes a new instance.
   *
   * @param message        The message of the exception.
   * @param innerException The inner exception.
   */
  public DuplicateException(String message, Exception innerException) {
    super(message, innerException);
  }

  /**
   * Initializes a new instance.
   *
   * @param innerException The inner exception.
   */
  public DuplicateException(Exception innerException) {
    super("", innerException);
  }

  @Override
  public String getMessage() {
    String baseMessage = super.getMessage();
    return StringUtils.isNotEmpty(baseMessage) ? baseMessage : "Duplicate Data";
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy