From 8eba78481c96ae40635e426b959fbcc8c020b43e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 28 Apr 2016 09:43:36 +0200 Subject: [PATCH] added new checked exception (derived from juser-core) --- .../exceptions/CustomerNotFoundException.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java diff --git a/src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java b/src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java new file mode 100644 index 0000000..d7bd493 --- /dev/null +++ b/src/org/mxchange/jcustomercore/exceptions/CustomerNotFoundException.java @@ -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 . + */ +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 + *

+ * @author Roland Haeder + */ +public class CustomerNotFoundException extends Exception { + + /** + * Serial number + */ + private static final long serialVersionUID = 57_382_175_461_975_680L; + + /** + * Constructor with already registered customer instance + *

+ * @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 + *

+ * @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 + *

+ * @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 + } + +} -- 2.39.5