Hey, im getting the following error

unreported exception Exceptions.IllegalValue; must be caught or declared to be thrown

this is my method where im getting the error and i want to know why im getting this error because i declared that the exception was to be thrown.
is it something to do with my if and else statements and where the brackets are located??

any suggestions greatly appreciated :)

/**
	 * adds an object to the front of the queue
	 * @param Object e, int p the object to add and the priority respectively
	 * @exception IllegalValue if the priority number is less than 0
	 */
	public void enqueue(Object e, int p) throws IllegalValue{ 
		if(p > 0)	{
			Iterator it = this.iterator();
			if (isEmpty() || p > front.priority) {
				front = new Link(e,p,front);
			} else {
				Link temp = (Link)it.next();
				while (it.hasNext() && temp.priority >= p) {
					it.next();
				}
					temp = new Link(e,p,temp);
			}
		}else throw new IllegalValue("illegal priority value");
		
	}

Is the error message referring to this method's code or the method that calls it?

it's referring to the method that calls it in my test file

q.enqueue(Integer.valueOf(1),1);

well i mean it happens when i try to compile my test code and not my code where that method is located

So there's nothing wrong with your method.
When you call a method that says it "throws IllegalValue", the calling method must either catch that exception or declare that it too will throw it up to whatever called it.

ah cool cheers yeh i changed the test file and now it works, thankyou!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.