Error is my code please help

I have created a try-catch statement, I have also created a home made Invalid value exception class. I have also thrown the InvalidValueException in a calculate method in a seperate class. I am getting the error of unreachable catch block. Here is my code for this process. Please Help
private void runPayroll(List employees)
Collections.sort(employees, new PersonComparator());
// place the following code in a try-catch statement to check for the following errors
//- InvalidValue (the pay units must be a decimal number > 0)
try
double payRate = jtfPayRate.getText();
catch (InvalidValueException ivEx)//THIS IS WHERE I AM GETTING MY ERROR
JOptionPane.showMessageDialog(this, "the pay units must be a decimal number > 0", "Error Message", JOptionPane.ERROR_MESSAGE);
return;
// loop through all of the employees in the collection
Iterator iterator = employees.iterator();
StringBuffer output = new StringBuffer("");
while (iterator.hasNext())
Employee employee = (Employee)iterator.next();
output.append( employee.toString() + "\n" );
//InvalidValueException class
public class InvalidValueException extends Exception
public  InvalidValueException(double payUnit)
//super(payUnit);
public String getLocalizedMessage()
return "Amount must be > 0";
//PayCheck class this is where I throw the exception
public abstract double calculate(double payUnit, double payRate)
throws InvalidValueException;

That catch block is never reached because
double payRate = jtfPayRate.getText();will never throw an InvalidValueException (it doesn't even know about it). I assume jtfPayRate is a textfield? If so, I am suprised the compiler doesn't give you an incompatible types error first, since you are trying to put a string into a double value with the above statement.
I think what you are trying to do is this:
try {
  double payRate = Double.parseDouble(jtfPayRate.getText());
catch(NumberFormatException ex) {
  throw new InvalidValueException(...);
}You may want to pass an error message string to your self made exception, by the way, and call super(message) in the constructor of it.

Similar Messages

  • HT5642 Unable to download app this time error while downloading app please help!!!

    when i download some app from apps store i get the following error
    "Unable to download app this time error while downloading app" please help!!!
    i ve tried these Things but
    didnt workout yet
    1) i tried hard reset
    2)i tried logout/login Itune & appstore
    3)Connected to pc and rest setting Network and Full Rest
    all of no use... i dont want to update my softwre from IOS 6.0
    Plx help!1

    Hey Prahaladvatsan,
    Thanks for the question. If I understand correctly, there is a blank app icon on the home screen. It looks like you have already done some troubleshooting. I would recommend that you read these articles, they may be helpful in troubleshooting your issue.
    Restart or reset your iPhone, iPad, or iPod touch - Apple Support
    Back up and restore your iPhone, iPad, or iPod touch using iCloud or iTunes - Apple Support
    Thanks for using Apple Support Communities.
    Have a good one,
    Mario

  • HT5676 my macpro (10.6.8) refused to install wireless printer (canon pixma MG4260). Whenever i tried to install, it keeps saying 'internal error number 12'. Please help!! and what does internal error got to do with installing a printer?

    my macbook pro (10.6.8) refused to install wireless printer (canon pixma MG4260). Whenever i tried to install, it keeps saying 'internal error number 12'. Please help me!! and what does internal error got to do with installing a printer?

    my macbook pro (10.6.8) refused to install wireless printer (canon pixma MG4260). Whenever i tried to install, it keeps saying 'internal error number 12'. Please help me!! and what does internal error got to do with installing a printer?

  • I have a compilation problem with my mini iPod that is preventing my volume from increasing. I can't get the compilation code, please help me

    MY mini iPod version number1.1.3 pc robs iPod ,4GB is having volume limit problem ,the volume is very low compare to how it was playing before I mistakenly touch the combination code. I have forgotten the combination code, please help me out.. I have tried to reset settings but it wouldn't work.

    i can get the combination code please

  • HT201263 Hi. I forgot my passcode and now I am unable to unlock my ipod. I tried restoring it using itunes in recovery mode as well as dfu mode but it says unable to restore,unknown error occured (3004).  Please help me out. My ipod is locked for one hour

    Hi. I forgot my passcode and now I am unable to unlock my ipod. I tried restoring it using itunes in recovery mode as well as dfu mode but it says unable to restore,unknown error occured (3004).  Please help me out. My ipod is locked for one hour now.

    Locked Out, Forgot Lock or Restrictions Passcode, or Need to Restore Your Device: Several Alternative Solutions
    1. iOS- Forgotten passcode or device disabled after entering wrong passcode
    2. iPhone, iPad, iPod touch: Wrong passcode results in red disabled screen
    3. Restoring iPod touch after forgotten passcode
    4. What to Do If You've Forgotten Your iPhone's Passcode
    5. iOS- Understanding passcodes
    6. iTunes 10 for Mac- Update and restore software on iPod, iPhone, or iPad
    Forgotten Restrictions Passcode Help
    You will need to restore your device as New to remove a Restrictions passcode. Go through the normal process to restore your device, but when you see the options to restore as New or from a backup, be sure to choose New.
    Also, see iTunes- Restoring iOS software.

  • How to fix this: The iphone "iPhone" could not be restored. An unknown error occurred (3014). Please help me :(

    how to fix this: The iphone "iPhone" could not be restored. An unknown error occurred (3014). Please help me

    Read here:
    http://support.apple.com/kb/ts3694#3014

  • Error install illustrator cc please help!!

    error install illustrator cc please help!!

    Eli,
    This may be one for this specialized forum (where you may be able find the answer from previous threads),
    http://forums.adobe.com/community/download_install_setup
    or for Customer Care (tick I Still Need Help and hope for an agent available for a chat),
    http://helpx.adobe.com/contact.html?product=illustrator&topic=downloading-installing-and-s etting-up
    or for Adobe Support (phone),
    http://helpx.adobe.com/adobe-connect/adobe-connect-phone-numbers.html

  • My macbook is blocked by pin code, please help, I dont know what to do!

    My macbook is blocked by pin code, please help, I dont know what to do!

    When you enter iTunes on the PC and the iPod icon pops up, right click on it and select "Options". Then click on the Music tab. Once you're in the Music tab check the box that says "Enable Disc Use". This means that you've just turned your iPod into a portable hard drive. Click "Ok" and move your iPod from the PC to the Mac. From there, your iPod should show up on the Mac's desktop right under the Hard Drive icon. Click "File" at the top of the screen and select "Add to Library". Find the iPod hard drive in the selection screen and choose the music folder that's on it. Then just click Ok and all your music will be downloaded. That should do the trick, but you might want to do a Google search on the subject to get a second opinion. Best wishes!

  • I have Mac Pro 2010 model and it's giving heavy fan noise,so run the Apple hardware test but it's showing the Error: 4SMC 1 40000000  please help me in this issue.

    I have Mac Pro 2010 model and it's giving heavy fan noise,so run the Apple hardware test but it's showing the Error: 4SMC 1 40000000  please help me in this issue.

    Same error information here.
    https://discussions.apple.com/message/13083664?messageID=13083664

  • Hello, I have downloaded the new update to my iPhone 4 but I can not instal it , gives me a error signs would you please help me thank you. Nasser

    Hello, I have downloaded the new update to my iPhone 4 but I can not instal it , gives me a error signs would you please help me thank you. Nasser

    Please identify the error.

  • Windows thinks my itouch is a camera and itunes says this ipod can't be used because the software isn't installed - reinstall itunes.  i've done that and continue to get the same error.  can someone please help?

    windows thinks my itouch is a camera and itunes says this ipod can't be used because the software isn't installed - reinstall itunes.  i've done that and continue to get the same error.  can someone please help?

    (apologies for barging in, lllass.)
    Let's try a standalone Apple Mobile Device Support install. It still might not install, but fingers crossed any error messages will give us a better idea of the underlying cause of why it's not installing under normal conditions.
    Download and save a copy of the iTunesSetup.exe (or iTunes64setup.exe) installer file to your hard drive:
    http://www.apple.com/itunes/download/
    Download and install the free trial version of WinRAR:
    http://www.rarlab.com/download.htm
    Right-click the iTunesSetup.exe (or iTunes64setup.exe), and select "Extract to iTunesSetup" (or "Extract to iTunes64Setup"). WinRAR will expand the contents of the file into a folder called "iTunesSetup" (or "iTunes64Setup").
    Go into the folder and doubleclick the AppleMobileDeviceSupport.msi (or AppleMobileDeviceSupport64.msi) to do a standalone AMDS install.
    (If it offers you the choice to remove or repair, choose "Remove", and if the uninstall goes through successfully, see if you can reinstall by doubleclicking the AppleMobileDeviceSupport.msi again.)
    Does it install (or uninstall and then reinstall) properly for you? If so, does your device connect without that message now?

  • TS1424 i keep getting error message not enough privileges and also error -1201 can someone please help

    i keep getting you do not have enough privileges when opening itunes as well as error 1201 can someone please help?

    See Here for Troubleshooting
    Free Disc Space
    http://www.thexlab.com/faqs/freeingspace.html
    See Here for Resolving Startup Issues
    http://support.apple.com/kb/ts1417

  • I am having problem when i am updating my iphone 4 to ios 5 ..it get update n took 50 minutes then at the end when it was processing file ...suddenly an error comes that an unknown error accurred {9006}..please help me..how will i update my iphone 4

    i am having problem when i am updating my iphone 4 to ios 5 ..it get update n took 50 minutes then at the end when it was processing file ...suddenly an error comes that an unknown error accurred {9006}..please help me..how will i update my iphone 4

    Error 9006: Following Troubleshooting security software frequently resolves this error. There may be third-party software installed that modifies your default packet size in Windows by inserting a TcpWindowSize entry into your Registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet size modification for assistance.

  • TS3694 I couldn't be update my iphone. An unknown error occurred (6). Please help me to resolve this problem.

    I could not be updated my iphone4. An unknown error is occurred(6). please help me to resolve this problem

    Errors related to third-party security software
    Error 2, 4 (or -4), 6, 1000, 9006
    Follow Troubleshooting security software. Often, uninstalling third-party security software will resolve these errors.
    There may be third-party software that modifies your default packet size in Windows by inserting a TcpWindowSize entry into your registry. Your default packet size being set incorrectly can cause these errors. Contact the manufacturer of the software that installed the packet size modification for assistance or follow this article by Microsoft: How to reset Internet Protocol (TCP/IP).
    Verify that access to ports 80 and 443 are allowed on your network.
    Verify that communication to albert.apple.com or phobos.apple.com is not blocked by a firewall, or other Internet security setting.
    Discard the .ipsw file, open iTunes and attempt to download the update again. See the steps underAdvanced Steps > Rename, move, or delete the iOS software file (.ipsw) below for file locations.
    Restore your device while connected to a different network.
    Restore using a different computer.

  • HT201304 ello my little brother has developed lock my iPhone and I could not see the unlocking code Please help and thank you

    Hello
    ello my little brother has developed lock my iPhone and I could not see the unlocking code Please help and thank you
    edited by host

    Hi Omar_a983,
    If you are having an issue with the passcode on your iPhone, you may find the following article helpful:
    iOS: Forgotten passcode or device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    Regards,
    - Brenden

Maybe you are looking for

  • If statement to put "Yes" or "No" in a table cell on another page

    Hello I have tried to find a solution to this and I just can't figure it out. I have gone through all of the messages and tried the examples and no go. Please help, thanks. THIS IS WHERE THE RADIO BUTTON IS: ----- form1.BorrowerInput.OtherPaymentsGro

  • Help please... i installed iOS 6 on my iphone 4g

    Please help.... I installed iOS 6 on my iphone 4g & it stuck on white screen.... i tried to "reboot" by holding the 2 buttons for 10 seconds & it didn't come back to life.... i connected to itunes & tried that route.... said "detected an iphone in re

  • Foreign currency debit, credit problem

    Hi Expert, My co they migrated newly new gl . FAGL_FC_VAL forex valuation, Instead debited the balance of the account its crediting, and some account instead of crediting the balance its debiting. I checked oba1, ftxp everthing perfectly its there. C

  • JVM OutOfMemory Heap Suddenly Rises

    Hi, Can anyone help me step by step to solve the Out Of Memory Issue we are facing in our application. After the restart the JVM runs perfectly fine for first 2 days ,the heap stablizes at 50%,but from 3rd day onward it starts shooting up and by 4th

  • I cant redownload my songs

    I want to redwnload my songs on Itunes, but when I go to purchases, the bubbles where words are supposed to be are blank, and only the outline of the bubble is there. Please help