Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A-RexCodeQuality #221

Merged
merged 12 commits into from
Nov 11, 2024
Merged

Conversation

rexkoh425
Copy link

improve error handling

@rexkoh425 rexkoh425 added the type.Enhancement An enhancement to an existing story label Nov 11, 2024
@rexkoh425 rexkoh425 added this to the v2.1 milestone Nov 11, 2024
@rexkoh425 rexkoh425 self-assigned this Nov 11, 2024
@AaronZZ10
Copy link

LGTM!!

Copy link

@CT9ARyan CT9ARyan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor indentation issues, otherwise LGTM!!👍

@@ -67,4 +67,5 @@ activate CustomerList
Parser <-- CustomerList : return
deactivate CustomerList
deactivate Parser
hide footbox

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!! 👍

try {
if(FileHandler.containEmptyParameter(parameters)){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add a space here after the if and the closing ) bracket.

@@ -99,6 +100,15 @@ private static void createFolder() {
}
}

public static boolean containEmptyParameter(String[] parameters){
for(int i = 0; i < parameters.length ; i++){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here maybe?? Add a space after the for??

@@ -121,6 +126,7 @@ public void addTransactionWithParameters(String[] parameters , ArrayList<Integer
boolean isCompleted = Boolean.parseBoolean(parameters[5]);
Transaction transaction = new Transaction(transactionId , carLicensePlate, borrowerName, duration,
startDate, isCompleted);

TransactionList.addTxWithoutPrintingInfo(transaction);
}catch (NumberFormatException | DateTimeParseException | CarException | TransactionException e){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe leave a space here before catch?

@@ -99,6 +100,15 @@ private static void createFolder() {
}
}

public static boolean containEmptyParameter(String[] parameters){
for(int i = 0; i < parameters.length ; i++){
if(parameters[i].trim().isEmpty()){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here?

while (scanner.hasNext()) {
scanLineAndAddTransaction(scanner, errorLines, line);
line ++;
}

if(!errorLines.isEmpty()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here?

@@ -89,6 +91,7 @@ public void loadTransactionDataIfExist(){
public void scanLineAndAddTransaction(Scanner scanner, ArrayList<Integer> errorLines, int line) {
String input = scanner.nextLine();
String[] parameters = input.split(" \\| ");

if(parameters.length != Transaction.NUMBER_OF_PARAMETERS){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well?

@@ -109,9 +112,11 @@ public void addTransactionWithParameters(String[] parameters , ArrayList<Integer
try {

String transactionId = parameters[0];
if(!Transaction.isValidTxId(transactionId)){

if(!Transaction.isValidTxId(transactionId) || FileHandler.containEmptyParameter(parameters)){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe here too??

@rexkoh425 rexkoh425 merged commit bab215e into AY2425S1-CS2113-T11-3:master Nov 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type.Enhancement An enhancement to an existing story
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants