*/
private void start (final String args[]) {
this.getLogger().info("Program is started."); //NOI18N
+ try {
+ // Init properties file
+ this.initProperties();
+ } catch (final IOException ex) {
+ // Something bad happened
+ this.abortProgramWithException(ex);
+ }
// Parse arguments
this.parseArguments(args);
import org.mxchange.jcore.application.Application;
import org.mxchange.jcore.contact.Contact;
import org.mxchange.jcore.contact.Gender;
+import org.mxchange.jcore.exceptions.BadTokenException;
import org.mxchange.jcore.exceptions.UnhandledUserChoiceException;
import org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException;
// Get manager and cast it
ManageableAddressbookContact manager = (ManageableAddressbookContact) this.getManager();
- // @TODO Rewrite this ugly switch() block
- switch (choice) {
- case '1':
- try {
- // Enter/add own data
- manager.doEnterOwnData();
- } catch (final ContactAlreadyAddedException ex) {
- // Already added
- this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
- }
- break;
-
- case '2': // Change own data
- manager.doChangeOwnData();
- break;
-
- case '3': // Add new addess
- manager.doAddOtherAddress();
- break;
-
- case '4': // List contacts
- manager.doListContacts();
- break;
-
- case '5': // Search addresses
- manager.doSearchContacts();
- break;
-
- case '6': // Change other addess
- manager.doChangeOtherAddress();
- break;
-
- case '7': // Delete other address
- manager.doDeleteOtherAddress();
- break;
+ // Try it!
+ try {
+ // @TODO Rewrite this ugly switch() block
+ switch (choice) {
+ case '1':
+ try {
+ // Enter/add own data
+ manager.doEnterOwnData();
+ } catch (final ContactAlreadyAddedException ex) {
+ // Already added
+ this.outputMessage("Sie haben bereits Ihre eigenen Daten eingegeben.");
+ }
+ break;
+
+ case '2': // Change own data
+ manager.doChangeOwnData();
+ break;
+
+ case '3': // Add new addess
+ manager.doAddOtherAddress();
+ break;
+
+ case '4': // List contacts
+ manager.doListContacts();
+ break;
+
+ case '5': // Search addresses
+ manager.doSearchContacts();
+ break;
+
+ case '6': // Change other addess
+ manager.doChangeOtherAddress();
+ break;
+
+ case '7': // Delete other address
+ manager.doDeleteOtherAddress();
+ break;
case '0': {
try {
}
break;
- default:
- // @TODO throw own exception
- throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N
+ default:
+ // @TODO throw own exception
+ throw new UnhandledUserChoiceException(MessageFormat.format("Choice '{0}' not handled yet.", choice)); //NOI18N
+ }
+ } catch (final IOException | BadTokenException ex) {
+ // Something bad happened
+ this.abortProgramWithException(ex);
}
// Trace message
import org.mxchange.jcore.client.gui.ClientFrame;
import org.mxchange.jcore.contact.Contact;
import org.mxchange.jcore.contact.Gender;
+import org.mxchange.jcore.exceptions.BadTokenException;
import org.mxchange.jcore.exceptions.FrameAlreadyInitializedException;
import org.mxchange.jcore.model.swing.contact.ContactTableModel;
* @param client Client instance
*/
@Override
- public void setupFrame (final Client client) {
+ public void setupFrame (final Client client) throws IOException, BadTokenException {
// Debug line
this.getLogger().trace(MessageFormat.format("client={0}: CALLED!", client)); //NOI18N
// Already added, log away
// @TODO maybe output message here?
self.logException(ex);
+ } catch (final IOException | BadTokenException ex) {
+ // Somethind bad happened here
+ // @TODO Output error message here?
}
}
});
@Override
public void actionPerformed (final ActionEvent e) {
ManageableAddressbookContact manager = (ManageableAddressbookContact) self.getClient().getManager();
- manager.doChangeOwnData();
+ try {
+ manager.doChangeOwnData();
+ } catch (final IOException | BadTokenException ex) {
+ self.logException(ex);
+ }
}
});
*
* @param manager Manager instance
* @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the database backend is not supported
- * @throws java.sql.SQLException If any SQL error occurs
+ * @throws java.sql.SQLException If an SQL error occurs
*/
public AddressbookContactDatabaseFrontend (final AddressbookContactManager manager) throws UnsupportedDatabaseBackendException, SQLException {
// Call own constructor
* a client instance.
*
* @param client Client instance to use
- * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the database backend is not supported
+ * @throws org.mxchange.jcore.exceptions.UnsupportedDatabaseBackendException If the configured database backend is not supported
* @throws java.sql.SQLException If an SQL error occurs
*/
public AddressbookContactManager (final Client client) throws UnsupportedDatabaseBackendException, SQLException {
* Allows the user to change his/her own data
*/
@Override
- public void doChangeOwnData () {
+ public void doChangeOwnData () throws IOException , BadTokenException{
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
* Asks user for own data
*/
@Override
- public void doEnterOwnData () throws ContactAlreadyAddedException {
+ public void doEnterOwnData () throws ContactAlreadyAddedException, IOException , BadTokenException {
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
* @return Value from given row/column
*/
@Override
- public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) {
+ public Object getValueFromRowColumn (final int rowIndex, final int columnIndex) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
// Trace message
this.getLogger().trace(MessageFormat.format("rowIndex={0},columnIndex={1} CALLED!", rowIndex, columnIndex));
* @return Whether own contact is already added
*/
@Override
- public boolean isOwnContactAdded () {
+ public boolean isOwnContactAdded () throws IOException, BadTokenException {
// Trace message
this.getLogger().trace("CALLED!"); //NOI18N
// Add contact to internal list
this.addContact(contact);
- } catch (final ContactAlreadyAddedException ex) {
- // Abort here
- this.abortProgramWithException(ex);
- } catch (final BadTokenException ex) {
+ } catch (final ContactAlreadyAddedException | BadTokenException | IOException ex) {
// Abort here
this.abortProgramWithException(ex);
}
*/
package org.mxchange.addressbook.manager.contact;
+import java.io.IOException;
import org.mxchange.addressbook.exceptions.ContactAlreadyAddedException;
import org.mxchange.jcore.contact.Contact;
import org.mxchange.jcore.contact.Gender;
+import org.mxchange.jcore.exceptions.BadTokenException;
import org.mxchange.jcore.manager.database.ManageableDatabase;
/**
/**
* Let the user change own data
+ * @throws java.io.IOException If an IO error was found
+ * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
*/
- public void doChangeOwnData ();
+ public void doChangeOwnData () throws IOException , BadTokenException;
/**
* Let the user delete other address
/**
* Asks user for own data
* @throws org.mxchange.addressbook.exceptions.ContactAlreadyAddedException If own contact is already added
+ * @throws java.io.IOException If an IO error was found
+ * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
*/
- public void doEnterOwnData () throws ContactAlreadyAddedException;
+ public void doEnterOwnData () throws ContactAlreadyAddedException, IOException , BadTokenException;
/**
* Searches address book for a contact
* isOwnContact flag
*
* @return Whether own contact is already added
+ * @throws java.io.IOException If an IO error occurs
+ * @throws org.mxchange.jcore.exceptions.BadTokenException If a bad token was found
*/
- public boolean isOwnContactAdded ();
+ public boolean isOwnContactAdded () throws IOException, BadTokenException;
}