Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

I dont know what I am doing wrong when I try to throw an exception

Below i have my method and my try and catch blocks but I do not know why I can't get it to just write awr or aws it throws the exception no matter what I write

public void rate(String rating)throws InvalidRate
{
if(!"awr".equalsIgnoreCase(rating) || !"aws".equalsIgnoreCase(rating))
/*rating != "AWR" || rating != "AWS")*/
throw new InvalidRate(rating);
rate=rating;
}
public String getRate()
{return rate;}


try
      {
      AWInfo f1=new AWInfo();
      System.out.println("Enter Aw Rate: ");
      Ar=keyboard.nextLine();
      f1.rate(Ar);
      System.out.println("Enter 1 for morning shift or 2 for evening shift");
      ws=keyboard.nextInt();
      f1.shift(ws);
      }
      catch(InvalidRate e){
      System.out.println(e.getMessage());}
       catch(InvalidShift e)
      {System.out.println(e.getMessage());}

the shift exception works fine.