Which exception should I throw?

For my program I created a simple parser class that will parse files in my custom file format for certain values. What exception should I throw if the specified value is not found in the file?

There's a NoSuchFieldException that seems close to what you are doing. Or create your own.

Similar Messages

  • How should i know which exception should i catch?

    hey all....
    i am getting the following error msgs (everything is compiled just fine..)
    I successfully translated the word car to αυτοκίνητο
    15 &#916;&#949;&#954; 2006 5:28:40 &#956;&#956; com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl <init>
    WARNING: "IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 10.34.153.11; port: 1541"
    org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No
         at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
         at com.sun.corba.se.impl.logging.ORBUtilSystemException.connectFailure(Unknown Source)
         at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
         at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.<init>(Unknown Source)
         at com.sun.corba.se.impl.transport.SocketOrChannelContactInfoImpl.createConnection(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaClientRequestDispatcherImpl.beginRequest(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaClientDelegateImpl.request(Unknown Source)
         at org.omg.CORBA.portable.ObjectImpl._request(Unknown Source)
         at WorkflowFramework._ServiceStub.translationService(_ServiceStub.java:18)
         at wF.ServantEnglishToGreek.translationService(ServantEnglishToGreek.java:294)
         at WorkflowFramework._ServiceImplBase._invoke(_ServiceImplBase.java:41)
         at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
         at com.sun.corba.se.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
         at com.sun.corba.se.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
         at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
         at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.doWork(Unknown Source)
         at com.sun.corba.se.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(Unknown Source)
    Caused by: java.net.ConnectException: Connection refused: connect
         at sun.nio.ch.Net.connect(Native Method)
         at sun.nio.ch.SocketChannelImpl.connect(Unknown Source)
         at java.nio.channels.SocketChannel.open(Unknown Source)
         at com.sun.corba.se.impl.transport.DefaultSocketFactoryImpl.createSocket(Unknown Source)
         ... 19 more
    NEXT SERVER IS DOWN! org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No when i am running a function on a remote object reference
    i have catched the exception and that is why the msg NEXT SERVER IS DOWN is printed..but how can i handle all the previous msgs?
    i searched a lot on the internet and i cannot find how to catch this error...
    all these msg seem to come from the java.net.ConnectException: Connection refused: connect but i dont have any statement that i can include in a catch try block so that i can do sth with that..(maybe print a msg..)
    btw the line from my code that this msg is refering to is the following
    try{
         //call next server
            nextServerRef.translationService(objRef, buffer);
    //      catch(java.net.ConnectException e){
    catch(Exception e){
              System.out.println("NEXT SERVER IS DOWN! "+e);
               }and btw i cannot include this code to the ConnectException because it keeps complaining that this code cannot throw this exception....
    any advice????
    ps.i have posted a specific msg to the rmi subforum...but i am trying to undestand the general process ..to look the wood not the trees;-)

    If the runtime exception occurs in a method that doesn't either catch it or declare it as being thrown, and you can't change the method, then there's not much you can do except diverting the output to a non-visible location, or a null sink.
    If you can change the method, you can either catch the exception and substitute your message, or you can change it to throw the method, and then catch the exception in a higher enclosing method, as I show:
    public static void main(String[] args)
        try
            some_method();
        catch (ConnectException ce)
            System.out.println("NEXT SERVER IS DOWN");
    static void some_method() throws ConnectException
        throw new ConnectException(); // create the exception
    }

  • Exception Handling Standards -The exception Exception should never been thrown. Always Subclass Exception and throw the subclassed Classes.

    In the current project my exception handling implementation is as follows :
    Exception Handling Layer wise :
    DL layer :
    catch (Exception ex)
    bool rethrow = ExceptionPolicy.HandleException(ex, "Ui Policy");
    if (rethrow)
    throw;
    BL Layer
    catch (Exception ex)
    bool rethrow = ExceptionPolicy.HandleException(ex, "Ui Policy");
    if (rethrow)
    throw;
    UI Layer
    catch (Exception ex)
    bool rethrow = ExceptionPolicy.HandleException(ex, "Ui Policy");
    if (rethrow)
    Response.Redirect("ErrorPage.aspx", false);
    We have a tool to check the standards. And tool output is as follows :
    The exception Exception should never been thrown. Always Subclass Exception and throw the subclassed Classes.
    I need suggestions on how to implement the same according to standards.

    Your tool is wrong if it says to never throw Exception.  This was a common recommendation back in the .NET v1 days but has long since been thrown out.  It is perfectly fine to use Exception when you have a general exception that provides no information
    that an application can use to make an informed opinion.
    The general rules of exception throwing is to throw the most specific exception that makes sense. If there is no specific exception that applies and it would be useful for the caller to handle the exception differently than other exceptions then creating
    a custom exception type is warranted.  Otherwise throwing Exception is reasonable. As an example you might have an application that pulls back product data given an ID. There is no built in exception that says the ID is invalid. However an invalid ID
    is something that an application may want to handle differently than, say, an exception about the product being discontinued.  Therefore it might make sense to create an ItemNotFoundException exception that the application can react to.
    Conversely there is no benefit in having different exception types for disk full and disk quota met. The application will respond the same in either case.
    Michael Taylor
    http://blogs.msmvps.com/p3net

  • Which Method Should be overriden to update a column in master?

    Hi,
    I have a Master/Detail relationship with the requirement to update master depending on some column in detail. This update of master can raise an exception and it should be done at post time. The way to update master changes depending on the DML action. If an exception is raised I want to rollback the changes made to master.
    I tried prepareForDML, postChanges methods. In both cases the exception is ignored and the transaction is not commited and does not display any message visible. But the exception can be catched and visible on console.
    I tried creating a validation method on detail entity. In the validation method I update master and call master.validate. This seems to work but the validation method can be called more than once and thus can update master more than once which is invalid.
    So which method should I use to post changes of the master?
    I present detail data as a ADF-Table. I want to display the exception as attached to a row in ADF-Table, just below the row in the table. Is it possible?
    Regards,
    Salim

    Jan,
    I have OrderItems and deliveryItems entities with 1..* relationship. I want to update OrderItems.deliveredQuantity and OrderItems.returnedQuantity fields based on delivery Type (i.e return, accept). OrderItems entity has an entity-level validation rule as quantity >= deliveredQuantity - returnedQuantity. So it might throw exceptions on Validate.
    I decided to implement this functionality in deliveryItemsImpl.postChanges, deliveryItemsImpl.prepareForDML and finally in an entity level validation rule (method) in deliveryItemsImpl. In postChanges and PrepareForDML it just ignores the exception, does not commit, does not give any error messages. In the last case it retries to validate the entity continously and cannot validate. To my opinion it should stop saying this entity is invalid. Isn't?
    Jdev 10.1.3.3
    ADF-Faces, ADFBC
    Regards,
    Salim

  • What exception should I use when commit work fails ?

    hi all:
        I create a class with methods to insert , modify and delete trasaction data, 
    when commit work fails, I want to throw an exception, what exception should I use
    for this case?

    In general, you should do your commit using CALL FUNCTION IN UPDATE TASK. As this runs in a different process, you will never be able to catch an exception in your main task, even if you throw one in the Open SQL code. What you should do is carefully validate your data before posting it to the database, so that commit cannot fail for data integrity reasons. If it fails for technical reasons (DB down etc.) there is nothing that your code could do about it anyway, so in this case even getting an exception would be no use. What exactly is it you are trying to accomplish?
    -- Sebastian

  • Which one should i download?

    Hi All,
    I am doing a project in Sourceforge.net for that project i need to install mail server.so i thought of downloading JAMES from apache website..
    there are so many files in the page http://james.apache.org/download.cgi i was a bit confused to download which file under the heading Apache JAMES 2.3.1 is the best available version
    there are files like
    * Binary (Unix TAR): james-binary-2.3.1.tar.gz [PGP]
    * Binary (ZIP Format): james-binary-2.3.1.zip [PGP]
    * Mailet SDK (Unix TAR): james-MailetSDK-2.3.1.tar.gz [PGP]
    * Mailet SDK (ZIP Format): james-MailetSDK-2.3.1.zip [PGP]
    * Source (Unix TAR): james-2.3.1-src.tar.gz [PGP]
    * Source (ZIP Format): james-2.3.1-src.zip [PGP]
    * Source with Avalon Phoenix binaries (Unix TAR): james-with-phoenix-2.3.1-src.tar.gz [PGP]
    * Source with Avalon Phoenix binaries (ZIP Format): james-with-phoenix-2.3.1-src.zip [PGP]
    * Other Binaries
    which one should i download and install to configure mail server..
    Please help me...
    Thanks in Advance,
    Ramesh Ale

    Unless you need the source you would normally download the binary distributions - either james-binary-2.3.1.tar.gz(Linux/Unix) or james-binary-2.3.1.zip (Windows). Since the two are essentially the same except for the compression method you can download either. It just depends on which one you can 'decompress'.
    Note: Though it is a couple of years since I installed and used James, it was my experience that some service providers do not accept emails sent through James. It seems there is some form of registration system in place.

  • Which listener should be used for JTextArea

    Hi,
    I need to add a listener for JTextArea particualy when
    the text in the jtextarea is changed. I don't think
    mouse listener is enough, since the user can use tab to
    get to the jtextarea and edit the text. In this case,
    which listener should I use. Sample code would be
    helpful.
    In addition, I have a problem with the jtextarea that
    when user uses tab to go to different gui components,
    such as jtextfield, jcombobox, jtextarea, jlist, etc, the
    tab stays in the jtextarea and keeps appending to it. It does
    not go to next component, such as jlist. How can I make it
    work?
    Thanks in advance,
    Pin

    It doesn't work. Are you using 1.4 or 1.3? I am using
    1.4.
    In the 1.4 API, it says that isManagingFocus is
    "Deprecated".
    Here is what I have:
    JTextArea descrptArea = new JTextArea() {
    public boolean isManagingFocus() {
    return false;
    descrptArea.setRows(3);
    descrptArea.setLineWrap(true);
    descrptArea.addKeyListener(new KeyAdapter() {
    public void keyTyped(KeyEvent e) {
    // DO SOMETHING
    I found the following code which says it will do it.
    However, I got the exeception:
    java.lang.ClassCastException:
    n: javax.swing.KeyStroke
    at java.util.TreeMap.compare(TreeMap.java:1081)
    at java.util.TreeMap.put(TreeMap.java:459)
    at java.util.TreeSet.add(TreeSet.java:205)
    Set forwardTraversalKeys = new TreeSet();
    forwardTraversalKeys.add(KeyStroke.getKeyStroke('\t'));
    forwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEven
    .VK_TAB,
    InputEvent.CTRL_MASK));
    textArea.setFocusTraversalKeys
    (KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,
    forwardTraversalKeys);
    Set backwardTraversalKeys = new TreeSet();
    backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEve
    t.VK_TAB,
    InputEvent.SHIFT_MASK));
    backwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEve
    t.VK_TAB,
    InputEvent.SHIFT_MASK |InputEvent.CTRL_MASK));
    textArea.setFocusTraversalKeys(
    KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS,
    backwardTraversalKeys);
    Any idea???
    PinI'm not using 1.4 but the class cast exceptions look like they come from : Set forwardTraversalKeys=new TreeSet() etc
    try : TreeSet forwardTraversalKeys=new TreeSet()
    you cant cast from a Set to a TreeSet because a TreeSet is a Set but a Set is NOT a TreeSet.
    hope this helps.

  • Which exception is thrown?

    Which exception is thrown when a native method breaks?
    For example: when a native method cannot access some device.
    Is it RunTimeException, or just plain Exception, or perhaps something else?
    Thanks.

    The native - C - code is yours. If it encounters an
    error, it is up to you to decide how to deal with it.No. Im using someone elses native methods.
    Chances are, if you are trying to write a wrapper
    around someone elses code...Exactly! :)
    ... you will find the code
    throws C++ exceptions. You have to catch them and
    deal with them.I know that. That is why I posted a question here. Question is: What is that exception?
    One likely way to "deal with them" is to define for
    yourself the exceptions you would like to see in
    java, and have the native methods construct and throw
    those java exceptions. The JNI interface includes
    ways of throwing exceptions while in native code.I don't know that. If you could provide some example it would be most appreciated.
    Thanks.

  • Which services should be moved to a new SharePoint Enterprise Application server?

    Our farm is currently a WFE and a SQL server. I've been tasked with creating a new SP Enterprise Application/Search server.
    Which services should be moved? This is what's currently listed in Services on Server:
    Access Database Service  Started  Stop 
    Application Registry Service  Started  Stop 
    Business Data Connectivity Service  Started  Stop 
    Central Administration  Started  Stop 
    Claims to Windows Token Service  Started  Stop 
    Document Conversions Launcher Service  Stopped  Start 
    Document Conversions Load Balancer Service  Stopped  Start 
    Excel Calculation Services  Started  Stop 
    Lotus Notes Connector  Stopped  Start 
    Managed Metadata Web Service  Started  Stop 
    Microsoft SharePoint Foundation Incoming E-Mail  Started  Stop 
    Microsoft SharePoint Foundation Sandboxed Code Service  Stopped  Start 
    Microsoft SharePoint Foundation Subscription Settings Service  Stopped  Start 
    Microsoft SharePoint Foundation Web Application  Started  Stop 
    Microsoft SharePoint Foundation Workflow Timer Service  Started  Stop 
    PerformancePoint Service  Started  Stop 
    Search Query and Site Settings Service  Started  Stop 
    Secure Store Service  Started  Stop 
    SharePoint Foundation Search  Stopped  Start 
    SharePoint Server Search  Started  Stop 
    User Profile Service  Started  Stop 
    User Profile Synchronization Service  Started  Stop 
    Visio Graphics Service  Started  Stop 
    Web Analytics Data Processing Service  Started  Stop 
    Web Analytics Web Service  Started  Stop 
    Word Automation Services  Started  Stop 

    Take a look at http://www.microsoft.com/en-us/download/details.aspx?id=37000. It should help you decide where it is most appropriate to locate services.
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Sharepoint 2013 - Which Server Should Run Microsoft SharePoint Foundation Sandboxed Code Service

    We have just deployed Sharepoint 2013 and also CRM 2011..
    Our Sharepoint 2013 Environment has a WFE and an APP server and we have a CRM 2011 box.
    We have been getting the following error in IE when Users in CRM are clicking on the Document Link under accounts which links to Sharepoint 2013
    "This Content cannot be displayed in a frame
    To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame."
    It seems like it is a IE Security Issue, but I am suspecting it could be the Microsoft SharePoint Foundation Sandboxed Code Service.
    Which server should be running the Microsoft SharePoint Foundation Sandboxed Code Service| WFE or APP.
    Also which server should run the Windows Service: SharePoint User Code Host
    Thank you in advance.

    Hi,
    Please have a look at the following post:
    http://technet.microsoft.com/en-us/library/jj219591.aspx
    As it describes, the recommendation is for both services to start it on the Web Front End servers.
    Cheers,
    Vincent

  • Multiple Apple ID's, which one should be main iCloud ID on iOS 5?

    Hey!  Seems like iCloud is a bit more complex to setup than I had thought it would be.  Here's the situation.  I have two Apple ID's.  One is my @me.com account that I just migrated to iCloud.  Second Apple ID is an @gmail.com account that I use for all of my iTunes purchases (also migrated to iCloud.  I know you can have multiple Apple ID's setup in iOS (by means of "Mail, Contacts, Calenders"), but there is only room for one account under the "iCloud" tab/setting under iOS settings.  Which one should be used here?  My @me.com, or the one I use for iTunes purchases? ...or does it even matter?  Just want to set everything up optimally from the start so I don't have to go back later and correct something.
    Thanks all for your assistance!

    Try here >  Apple IDs and iCloud

  • Firefox 4 seems to action on some html tags that are included within a html comment tag which it should not.

    Consider the following html code where I open a textarea and include a comment tag within the textarea. Within the comment tag (which Firefox 4 should ignore) I've included a close textarea tag. Firefox 4 (unlike FF3 and IE) closes the textarea.
    The following code is also available at
    http://www.cems.uwe.ac.uk/caa/ffbug/index.html
    We are about to start a textarea....<p>
    <pre><nowiki><textarea rows='20' cols='40'>
    Here is the textarea.
    Inside these comment blocks I'll put a close textarea tag which Firefox should ignore but does not.
    <p>
    <!--
    We are now inside comment blocks...
    <br>
    This code should be inside the text area.<br>
    </textarea>
    <br>
    and so should this code be <b>inside</b> the text area (but is not in Firefox 4).
    -->
    </textarea>
    <p></nowiki></pre>
    This code should be outside the textbox.

    Try posting at the Web Development / Standards Evangelism forum at MozillaZine. The helpers over there are more knowledgeable about web page development issues with Firefox. <br />
    http://forums.mozillazine.org/viewforum.php?f=25 <br />
    You'll need to register and login to be able to post in that forum.

  • Why do I have both photoshop cc and photoshop cc (64 bit) in my menu? Which one should I be using?

    Why do I have both photoshop cc and photoshop cc (64 bit) in my menu? Which one should I be using?

    The majority of the time using the 64 bit version is better, since you have more resources available (ram)
    If you need to run some older third party plugins that were only ever offered as 32 bit plugins, then the 32 bit version is the choice.
    Or if you happen to use a scanner with twain, then the 32 bit version.

  • I have a airport time capsule, an older airport extreme, and an airport express.  I want to hard wire my Mac Mini to the network.  What is the best arrangement of the devices?  which ones should be hard wired to optimize extending the network?

    I have a airport time capsule, an older airport extreme, and an older airport express.  I want to hard wire my Mac Mini to the network.  What is the best arrangement of the devices?  which ones should be hard wired to optimize extending the network?

    I am using TM Unifi with an ASUS RT-N18U Wi-Fi router.  I would like to know could I use Apple AirPort Time Capsule to extend (repeater, booster) my Wi-Fi to a part of the house where the Wi-Fi signal is poor
    Yes,, if you plan to connect the AirPort Time Capsule to the ASUS router using an Ethernet cable connection that will remain fixed and permanently installed at all times.
    No, if you were planning to have the AirPort Time Capsule connect wirelessly and extend the Asus WiFi signal, since it would not be compatible with another manufacturer's router for that purpose.
    Another way of saying the same thing here would be that if you want to extend the network wirelessly, it will take two Apple routers to do so

  • I'm 51 years old and recently retired. I have a new IPad Air. Which MacBook should I buy to go with it?  I don't understand flash storage.  It feels like I would have a bunch of flash drives to keep up with.  Help an old lady out!!!

    I'm 51 years old and recently retired. I have a new IPad Air. Which MacBook should I buy to go with it?  I don't understand flash storage.  It feels like I would have a bunch of flash drives to keep up with.  Help an old lady out!!!

    Depends on how you want to use it. Flash storage on the newer macbook and macbook air are built in. A macbook air is the most light weight and a very good machine. It will do all you want it to do unless you are running some very intensive programs. If you go to the apple store on line you can compare  the different macbook pro" and macbook Air's.

Maybe you are looking for

  • Get the Value copy from Header feild to Line feild through Persnalization

    Hi, I have one requirement. I have a field in Header level. When I have assigned some value to that field in header level at the same time the same field at line level also has the same value and when I Query the form and changed some value on that f

  • Powerbook 1400 and OS 9.2.x

    With only 64MB of ram max, can this computer be upgraded to 9.2.x? I thought I read somwhere that 9.1 was as far as I can go with a PB 1400. Thanks for your help!! Jim

  • Impromptu slideshow always fails second time?

    Hey, Well, the subject says it all. Impromptu slideshow always fails second time. I press the menu item and nothing happens (I have photos selected). It works great when I quit LR4 and then restart and select the photos again, but only first time...b

  • AIR for Android - see only white screen

    I want deploy my AIR application on Android device (created by Flash Builder)  - but I see only white screen on Android-device. In development environment - I install Flex 4.6 with upgrade it to AIR 3.7 In Android I install current AIR envirenment fo

  • How to get missing year and months

    hi,    I have to get count of each month of each year using SP the parameters are date range , it can be more than one year. the problem is, in database there is data for few months only , but user can enter a big date range. and i have show each mon