class WrongNumberException extends Exception { private int num; WrongNumberException(int num) { this.num = num; } @Override public String toString() { String msg; if (num == 0) { msg = "Error! Zero number!"; }else if(num < 0) { msg = "Error! Negative number!"; }else { msg = "Error! Other error!"; } return msg; } } class App { static int kerSzam() { return -9; } public static void main(String args[]) throws Exception { int szam = kerSzam(); if(szam<=0) throw new WrongNumberException(szam); else System.out.println("A szam: " + szam); } }