Помогите, пожалуйста, найти ошибку. Для отрицательных чисел бросает исключение, если строка - тоже.
package com.javarush.task.task14.task1420;
/*
НОД
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
public static void main(String[] args) throws Exception {
int a, b, nod = 1, maxNod = 1;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
a = Integer.parseInt(reader.readLine());
b = Integer.parseInt(reader.readLine());
if (a < 0 || b < 0) {
throw new Exception("Expection");
}
while (nod <= Math.max(a, b)) {
if ((a % nod == 0) && (b % nod == 0)) {
maxNod = nod;
}
nod++;
}
System.out.println(maxNod);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
}