]> git.mxchange.org Git - jcustomer-core.git/commitdiff
added new checked exception (derived from juser-core)
authorRoland Häder <roland@mxchange.org>
Thu, 28 Apr 2016 07:43:36 +0000 (09:43 +0200)
committerRoland Häder <roland@mxchange.org>
Thu, 28 Apr 2016 08:16:56 +0000 (10:16 +0200)
src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java [new file with mode: 0644]

diff --git a/src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java b/src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java
new file mode 100644 (file)
index 0000000..d7bd493
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcustomercore.exceptions;
+
+import java.text.MessageFormat;
+import org.mxchange.jcustomercore.model.customer.Customer;
+
+/**
+ * An exception thrown when the user's account was not found
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+public class CustomerNotFoundException extends Exception {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 57_382_175_461_975_680L;
+
+       /**
+        * Constructor with already registered customer instance
+        * <p>
+        * @param customer Customer instance
+        */
+       public CustomerNotFoundException (final Customer customer) {
+               // Call super contructor
+               super(MessageFormat.format("Customer {0} not found.", customer)); //NOI18N
+       }
+
+       /**
+        * Constructor with customer id
+        * <p>
+        * @param customerId Customer id
+        */
+       public CustomerNotFoundException (final Long customerId) {
+               // Construct message
+               super(MessageFormat.format("Customer id {0} not found.", customerId)); //NOI18N
+       }
+
+       /**
+        * Constructor with customer id and causing exception
+        * <p>
+        * @param customerId Customer id
+        * @param cause Causing exception
+        */
+       public CustomerNotFoundException (final Long customerId, final Throwable cause) {
+               // Construct message
+               super(MessageFormat.format("Customer id {0} not found. Cause: {1}", customerId, cause.getMessage()), cause); //NOI18N
+       }
+
+}