From a9f5b2231a11ead9a92a9173672aa0ac4e2f67f0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 8 Jun 2017 21:08:25 +0200 Subject: [PATCH] added exceptions which origins from jcontacts-core MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../BusinessContactAlreadyAddedException.java | 50 ++++++++++++++ .../BusinessContactNotFoundException.java | 65 +++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactAlreadyAddedException.java create mode 100644 src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactNotFoundException.java diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactAlreadyAddedException.java b/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactAlreadyAddedException.java new file mode 100644 index 0000000..82937c7 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactAlreadyAddedException.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.exceptions; + +import java.text.MessageFormat; +import org.mxchange.jcontactsbusiness.BusinessContact; + +/** + * Thrown if the given BusinessContact instance is already added + *

+ * @author Roland Häder + */ +public class BusinessContactAlreadyAddedException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 75_844_851_467L; + + /** + * Constructor with a Contact instance + *

+ * @param businessContact Business contact that is already added + */ + public BusinessContactAlreadyAddedException (final BusinessContact businessContact) { + super(MessageFormat.format("Business contact with businessContactId={0} not found.", businessContact.getBusinessContactId())); //NOI18N + } + + /** + * Default constructor, may be used if no contact instance is available + */ + public BusinessContactAlreadyAddedException () { + super("BusinessContact already added"); //NOI18N + } + +} diff --git a/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactNotFoundException.java b/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactNotFoundException.java new file mode 100644 index 0000000..6368041 --- /dev/null +++ b/src/org/mxchange/jcontactsbusiness/exceptions/BusinessContactNotFoundException.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.mxchange.jcontactsbusiness.exceptions; + +import java.text.MessageFormat; + +/** + * An exception thrown when a contact (entity) has not found. + *

+ * @author Roland Häder + */ +public class BusinessContactNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 23_759_801_876_416_568L; + + /** + * Constructor with business contact id + *

+ * @param businessContactId Business contact id + */ + public BusinessContactNotFoundException (final Long businessContactId) { + // Call super constructor with message and cause + super(MessageFormat.format("Business contact with id {0} was not found.", businessContactId)); //NOI18N + } + + /** + * Constructor with business contact id and causing exception + *

+ * @param businessContactId Business contact id + * @param cause Causing exception + */ + public BusinessContactNotFoundException (final Long businessContactId, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Business contact with id {0} was not found.", businessContactId), cause); //NOI18N + } + + /** + * Constructor with email address and causing exception + *

+ * @param emailAddress Email address + * @param cause Causing exception + */ + public BusinessContactNotFoundException (final String emailAddress, final Throwable cause) { + // Call super constructor with message and cause + super(MessageFormat.format("Business contact with email address {0} was not found.", emailAddress), cause); //NOI18N + } + +} -- 2.39.2