use of SMExceptions.CommonExceptions.CriticalError in project SmartCity-Market by TechnionYP5777.
the class RegisteredCustomer method updateCustomerProfile.
@Override
public void updateCustomerProfile(CustomerProfile p) throws CustomerNotConnected, InvalidParameter, AuthenticationError, CriticalError {
String serverResponse;
log.info("Creating updateCustomerProfile command wrapper to customer with username: " + p.getUserName());
establishCommunication(CustomerDefs.port, CustomerDefs.host, CustomerDefs.timeout);
/* first: getting the product from the server */
try {
serverResponse = sendRequestWithRespondToServer(new CommandWrapper(id, CommandDescriptor.UPDATE_CUSTOMER_PROFILE, Serialization.serialize(p)).serialize());
} catch (SocketTimeoutException e) {
log.fatal("Critical bug: failed to get respond from server");
throw new CriticalError();
}
terminateCommunication();
CommandWrapper $ = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler($.getResultDescriptor());
} catch (InvalidCommandDescriptor | CriticalError | AmountBiggerThanAvailable | ProductPackageDoesNotExist | GroceryListIsEmpty | ProductCatalogDoesNotExist | UsernameAlreadyExists | ForgotPasswordWrongAnswer ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
customerProfile = p;
log.info("updateCustomerProfile command succeed.");
}
use of SMExceptions.CommonExceptions.CriticalError in project SmartCity-Market by TechnionYP5777.
the class RegisteredCustomer method removeCustomer.
@Override
public void removeCustomer() throws CustomerNotConnected, InvalidParameter, AuthenticationError, CriticalError {
String serverResponse;
log.info("Creating removeCustomer command wrapper to customer with username: " + customerProfile.getUserName());
establishCommunication(CustomerDefs.port, CustomerDefs.host, CustomerDefs.timeout);
/* first: getting the product from the server */
try {
serverResponse = sendRequestWithRespondToServer(new CommandWrapper(id, CommandDescriptor.REMOVE_CUSTOMER, Serialization.serialize(customerProfile.getUserName())).serialize());
} catch (SocketTimeoutException e) {
log.fatal("Critical bug: failed to get respond from server");
throw new CriticalError();
}
terminateCommunication();
CommandWrapper $ = getCommandWrapper(serverResponse);
try {
resultDescriptorHandler($.getResultDescriptor());
} catch (InvalidCommandDescriptor | CriticalError | AmountBiggerThanAvailable | ProductPackageDoesNotExist | GroceryListIsEmpty | ProductCatalogDoesNotExist | UsernameAlreadyExists | ForgotPasswordWrongAnswer ¢) {
log.fatal("Critical bug: this command result isn't supposed to return here");
throw new CriticalError();
}
log.info("removeCustomer command succeed.");
}
use of SMExceptions.CommonExceptions.CriticalError in project SmartCity-Market by TechnionYP5777.
the class IsFreeCustomerNameTest method isFreeCustomerNameConnectionFailureTest.
@Test
public void isFreeCustomerNameConnectionFailureTest() {
try {
Mockito.when(clientRequestHandler.sendRequestWithRespond(new CommandWrapper(CustomerDefs.loginCommandSenderId, CommandDescriptor.IS_FREE_CUSTOMER_NAME, Serialization.serialize(username)).serialize())).thenThrow(new SocketTimeoutException());
} catch (IOException ¢) {
fail();
}
try {
customer.isFreeUsername(username);
fail();
} catch (CriticalError e) {
/* success */
}
}
use of SMExceptions.CommonExceptions.CriticalError in project SmartCity-Market by TechnionYP5777.
the class ManageEmployeesTab method finishBtnPressed.
@FXML
void finishBtnPressed(ActionEvent __) {
try {
manager.registerNewWorker(new Login(userTxt.getText(), passTxt.getText(), new ForgotPasswordData(securityCombo.getSelectionModel().getSelectedItem(), securityAnswerTxt.getText())));
} catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | WorkerAlreadyExists e) {
log.fatal(e);
log.debug(StackTraceUtil.getStackTrace(e));
e.showInfoToUser();
}
createEmployeesList();
enableRemoveButton();
}
use of SMExceptions.CommonExceptions.CriticalError in project SmartCity-Market by TechnionYP5777.
the class ManageCatalogProductDetailsTab method renameIngrPressed.
void renameIngrPressed() {
long id = ingredients.get(selectedIngr.iterator().next()).getId();
try {
manager.editIngredient(new Ingredient(id, renameIngrLbl.getText()));
} catch (InvalidParameter | CriticalError | EmployeeNotConnected | ConnectionFailure | ParamIDDoesNotExist e) {
log.debug(StackTraceUtil.getStackTrace(e));
log.fatal(e);
e.showInfoToUser();
}
selectedIngr.clear();
createIngredientList();
enableButtons();
enableAddButtons();
}
Aggregations