I'm trying to understand exceptions and I'm getting errors when I try to implement a custom one I made. I was given directions to make a no constructor that passes the string below to the super constructor. I keep getting compiler errors and I'm not sure how to fix them. The custom file looks like this
import java.io.*;
public class UnknownRegionException extends FileNotFoundException {
public UnknownRegionException() {
super("Could not find your region!");
}
}
and this block of code isn't running properly
public Adventure(String file) {
try {
File inFile = new File(file);
Scanner scan = new Scanner(inFile);
int i = 0;
while (scan.hasNext()) {
String name = scan.nextLine();
pokemon[i] = name;
i++;
}
} catch (UnknownRegionException e) {
System.err.println(e);
}
}
The errors i'm getting are below
D:\Documents\Google Drive\Homework\1331\HW8>javac Adventure.java
Adventure.java:23: error: unreported exception FileNotFoundException; must be ca
ught or declared to be thrown
Scanner scan = new Scanner(inFile);
^
Adventure.java:63: error: unreported exception PokemonAlreadyExistsException; mu
st be caught or declared to be thrown
throw new PokemonAlreadyExistsException(message);
^
Adventure.java:78: error: unreported exception PokemonAlreadyExistsException; mu
st be caught or declared to be thrown
throw new PokemonAlreadyExistsException();
^
Adventure.java:84: error: unreported exception PartyIsFullException; must be cau
ght or declared to be thrown
throw new PartyIsFullException();
^
Adventure.java:99: error: unreported exception FileNotFoundException; must be ca
ught or declared to be thrown
PrintWriter outWriter = new PrintWriter(outFile);
^
5 errors