Skip to content

Instantly share code, notes, and snippets.

@mcsee
Last active February 20, 2024 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcsee/029e21221849e251babf8d933170e62f to your computer and use it in GitHub Desktop.
Save mcsee/029e21221849e251babf8d933170e62f to your computer and use it in GitHub Desktop.
public class FileReader {
public static void main(String[] args) {
FileReader file = null;
try {
file = new FileReader("source.txt");
file.read();
}
catch(FileException exception) {
if (exception.description ==
(this.expectedMessages()
.errorDescriptionFileTemporaryLocked(){
// sleep and retry
// IF behavior is the same with all the exceptions
// just change the text on
// object creation and raise the correct instance
}
this.showErrorToUser(exception.messageToUser();
// This example is simplified.
// You should translate the text
}
finally {
try {
file.close();
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment