WesleyyC / Image-Editor

A command line image editor written in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Better error handler in Editor

SerinaTan opened this issue · comments

Migrated some of the tasks from #3 here.
We need a better mechanism to handle wrong user input instead of giving up with errors, such as looping through to prompt the user to try again.

-The handler in 'replace' should be improved: I don't think continue is the best way to do with the error input here. Maybe we can set up a loop to prompt user for input until we get an expected one. Also,regarding InputMismatchException, it is not a good practice to use exception as part of the control flow in a program. Exceptions are expensive and I would recommend avoid it here. In cases where we can expect how the user is typing in the wrong output, we can just add a check and prompt the user for input again.
-In loadImage() Maybe we can combine two try and catch block together?

I have done some try/catch redesign in the loadImage. I also attempted to catch the memory heap error with higher resolution in TheImage.java unpack(), but failed.