From: Roland Häder Date: Thu, 8 Jun 2017 19:08:25 +0000 (+0200) Subject: added exceptions which origins from jcontacts-core X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a9f5b2231a11ead9a92a9173672aa0ac4e2f67f0;p=jcontacts-business-core.git added exceptions which origins from jcontacts-core Signed-off-by: Roland Häder --- 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 + } + +}