Writing Exception

I am trying to figure out the best way to write exception classes for my program. I think i have 2 choices:
1) For each type of user exception I create an Exception class. All of them are inherited from java.lang.Exception. So for example I have
public class LocationNotFoundException extends Exception {
2) Write Exception classes based on the level of code. So any basic exception will throw InfrastructureException:
public class InfrastructureException extends Exception {
Then if exception happens in DAO then DAOException:
public class DAOException extends InfrastructureException {
Is there any other choice? Which approach is better and why?
Thanks

I think the idea is to write different Exceptions for
different means of failure that need to be handled
differently. If two Exceptions are being used where
they differ only in the information being conveyed,
but neither warrants handling the situation much
differently, they can be smushed into one.
~CheersThanks. So if I have LocationNotFoundException and DepartmentNotFoundException and both are same in functionality, its better to instead define ObjectNotFoundException and use it instead?
How about using inheritance between these Exceptions? Is it a recommended approach?

Similar Messages

  • Writing Exception into ccBPM container trace from Graphical mapping

    Hi guys,
    I followed the Guarneri's blog /people/alessandro.guarneri/blog/2006/01/26/throwing-smart-exceptions-in-xi-graphical-mapping
    It works fine within message monitor, but at the trace of ccBPM nothing appears! I'm talking about the trace of the container at the message mapping in the ccBPM. (I increased the trace level, but didn't solve)
    Anyone knows if it is possible to use this approach for the ccBPM container trace as well, or I'm missing something here?
    Thanks in advance & regards,
    Ricardo.

    Hi Gonzalo,
    you wrote:
    >>Mark the tag 'Create new transaction' in your transformation step in your BPM. Then navigating in the sxmb_moni_bpe transaction wil bring you to your message. But it is hard to find the XML there.
    The low technology solution is simulating the data flow in your bpm throw a sequence of chained mapping tests. <<
    I already have the option "create new transaction". but maybe I'm searching in the wrong place. Could you point me where to find at ccBPM?
    Thanks &regards,
    Ricardo.

  • Writing Exception.printStackTrace to a string

    Hi,
    I need to write the exception strack trace to a String so that I can email it details of exceptions on a web site to a system administrator.
    The printStackTrace() method prints exactly what I want to an OutputStream (such as system.out) but I don't know how I can get this into a string. Simply doing Exception.toString() does not produce enough detail about the exception to make it useful.
    Can anyone help?
    Below is some code that demonstrates what I'm trying to do but does not work because the printStackTrace() method on the exception object doesn't write to a string.
    try {
    // Some exception here, in this case / by 0
    int i = 7 / 0;
    catch (Exception e) {
    // This is too short and does not give enough information
    String exceptionInfoShort = e.toString()
    // This is what I want to do but it is not supported
    String exceptionInfoLong = e.printStackTrace();
    Cheers,
    Brent.

    No point messing about with PrintWriters and StringWriters. When you call e.printStackTrace() the method will construct a StringBuffer from every item in the stack trace and then print out the String representation of the buffer.
    You could do this yourself if only you could get the stack trace. Strangely, there is a method Exception.getStackTrace() that does exactly that (amasing what you can learn in two seconds from the API):
    void eMailStackTrace(Exception e) {
       StackTraceElement[] trace = e.getStackTrace();
       StringBuffer stackTraceBuffer = new StringBuffer();
       for(int i = 0 ; i < trace.length ; i++)
          stackTraceBuffer.append(trace.toString());
    String stackTrace = stackTraceBuffer.toString();
    email(stackTrace);

  • Public exception handler in database package

    I'm working on Oracle 10 g; I have a package with 10 functions, instead of writing exception for each individually is there is a way to do the same exception handler in all without repeating the exception handler in the 10 function (my exception handler is the same for the 10 function)

    It would depend on how you are using the functions, and what exactly your exception handler does.
    If, for example, your handler for no_data_found does a specific select statement, then you could put this statement in another function and call that function in the exception handler of each of the 10 functions. Note that you would need to catch the exception in eacg function, but the common code would be in one place. Something like:
    FUNCTION error_func RETURN NUMBER IS
    BEGIN
       SELECT other_stuff INTO var;
       RETURN var;
    END;
    function1 RETURN NUMBER IS;
    BEGIN
       SELECT stuff INTO var;
       RETURN var;
    EXCEPTION
       WHEN NO_DATA_FOUND
          effor_func;
    END;
    function2 RETURN NUMBER IS;
    BEGIN
       SELECT stuff INTO var;
       RETURN var;
    EXCEPTION
       WHEN NO_DATA_FOUND
          effor_func;
    END;
    function3 RETURN NUMBER IS;
    BEGIN
       SELECT stuff INTO var;
       RETURN var;
    EXCEPTION
       WHEN NO_DATA_FOUND
          effor_func;
    END;If you always run all 10 functions in sequence, then you could make a wrapper to call the functions, and catch exceptions in the wrapper. Something along the lines of:
    FUNCTION wrapper RETURN NUMBER IS;
    BEGIN
       function1;
       function2;
       function10;
    EXCEPTION
       WHEN NO_DATA_FOUND THEN
          do something;
    END;As constructed here, the wrapper wil not know which function errored nor will it continue running the other functions after getting an error.
    John

  • Upgrade batch inputs from 4.6C to mySAP ERP 2005

    Hi,
    we are planning to upgrade from 4.6C to mySAP ERP 2005 (ECC 6.0). We are using batch input/call transaction in various (interface) programs (primarily in modules SD, MM, CS/SM, FI, CO). I would be grateful for any information that helps to estimate the effort to upgrade our batch input code. In which areas/modules/transactions did you encounter problems with batch inputs? How severe were these problems (one or two fields moved to another screen, or major redesign)? How did you address these problems (change BI or convert code to use BAPI)?
    Thank you
    Thomas

    Hi thomas,
    we were working on batch input's and our scenario is something like convertion of bdc's from 4.5b to ECC5. well, it was a long process of upgradation. and coming to the part of BDC's
    Q) any information that helps to estimate the effort to upgrade our batch input code.
       we had 300 BDC's to convert from 4.5b to ECC5 and with a ten member team of ABAP experts it took us 30 working days to complete the process.
    Q) In which areas/modules/transactions did you encounter problems with batch inputs?
       Mostly, we had problems from FI and something like in Revenue recognition process. The problems comes, when the whole transactions screens changes for the process. at this time we have to write completly a new BDC's. if we have right functional specifications and functional experts, it will be easy to convert BDC's.
    Q) How severe were these problems (one or two fields moved to another screen, or major redesign)?
        As i have mentioned, out of 300 almost 25 to 50 were minor changes rest were huge changes.  a completely new BDC's. the point here is, we were updating from 4.5b to ECC5. it might not be this scenario for 4.6c to ECC5
    Q) How did you address these problems (change BI or convert code to use BAPI)?
       well, this is were we are curently working now. and curently there are 4 scenarios (and may be more in the future) were we have to replace three BDC's which are used for material master creation and make it into one bapi satisfying all the conditions of BDC's. actually, we have to find a BAPI( which i couldn't find) so, i have created a bapi. and tougher part is writing exceptions as we cannot write exceptions as we do in function module.
    hope this is relavent to what you have asked.
    cheers
    ajay

  • Premiere Elemente 12 - incompatible Display Driver on Win 8.1

    Hi Everybody!
    I am running Windows 8.1 on an HP Ultrabook equipped with 23" external Display via USB 3.0 Port Replicator. Primary Display is off, as Notebook is closed.
    I have installed PE12 before updating to W8.1.
    Starting PE 12 results in an alert message: "incompatible display driver detected, please update..."
    Updating Chipset Drivers resulted in "most recent driver installed".
    How can I get that software running???
    Thank you in advance
    Peter

    Have stopped the firewall and allowed all traffic -
    From what I have read, many of this type of situation has been resolved by disabling the firewall with the rationale that file like dynamiclinkmanager is being blocked from getting to important files because of firewall protection. If this turns out to be the case, then we would need to look into writing exceptions in the firewall.
    Removed the newest version and installaed 7.6.6. -
    Another strategy that worked for one with this type of problem was to go from the latest version of Quicktime to an earlier version. In the case that I read, the version went to was 7.6.6. Older versions of QuickTime can be found at the following link.
    Download Old Versions of QuickTime for Windows - OldVersion.com
    same result again - pe12 not starting.
    Does the copy of  error report from F-Secure help you:
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event"> 
    - <System> 
    <Provider Name="Windows Error Reporting" />  
    <EventID Qualifiers="0">1001</EventID>  
    <Level>4</Level>  
    <Task>0</Task>  
    <Keywords>0x80000000000000</Keywords>  
    <TimeCreated SystemTime="2014-06-16T21:02:14.000000000Z" />  
    <EventRecordID>24360</EventRecordID>  
    <Channel>Application</Channel>  
    <Computer>medvind-ABook</Computer>  
    <Security />  
    </System>
    - <EventData> 
    <Data />  
    <Data>0</Data>  
    <Data>APPCRASH</Data>  
    <Data>Ikke tilgængelig</Data>  
    <Data>0</Data>  
    <Data>Adobe Premiere Elements.exe</Data>  
    <Data>12.0.0.0</Data>  
    <Data>530bd24a</Data>  
    <Data>WorkspaceManager.dll</Data>  
    <Data>0.0.0.0</Data>  
    <Data>523cd2f7</Data>  
    <Data>c0000005</Data>  
    <Data>0000000000013070</Data>  
    <Data />  
    <Data />  
    <Data>C:\Users\medvind\AppData\Local\Temp\WER9A7C.tmp.WERInternalMetadata.xml</Data>  
    <Data>C:\Users\medvind\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_Adobe Premiere E_d162227a4febdf6c14e1c316fcd1d65b7c15bd5_2234ae4a</Data>  
    <Data />  
    <Data>0</Data>  
    <Data>7a2ee7ac-f599-11e3-ac1f-0090f5d6b56a</Data>  
    <Data>1</Data>  
    </EventData>
    </Event>
    I
    I have to stop for today

  • How can I erase my hard drive if my DVD is broken?

    Hi all,
    I have a G4 with OS 10.4.11 that I would like to now retire.
    The DVD drive is "stuffed up" so I cannot erase my files using the Tiger install disc.
    I went to applications/utilities/disk utility, selected the Macintosh HD, selected the Erase tab but all the writing (except erase free space button) is greyed out or dimmed.
    Any suggestions on what I may do next to erase my HD? Is there a firewire alternative? Thank-you in advance!!!
    Becks

    Hi Becky,
    My suggestion is similar to but not identical to Malcom's. His suggestion is you use the Target Disk mode to turn your old G4 basically into a hard drive that you other computer sees and erases. Should work but you may have some utility running on new computer that is not letting the drive unmount. For example, I have SMARTreporter running on my computer and it will not let me unmount other drives until I quit the application. You may have something similar which you have to track down.
    My suggestion was to make your firewire drive bootable, boot from that which then turns your internal drive into just another hard drive. Since you're booted from the Firewire drive you can erase the internal drive.
    One reason to wipe everything, including the OS, is the small possibility there are any personal bits of information or applications that somehow got put into the System area.

  • Batch logging -- what do you use?

    I have a new 10g database. We want to write some long running overnight batches. I wish to introduce a logging process. If we switch this on (ie set logging = yes) I want each process to write error and information messages to a new batch log file.
    In other databases we have written some in house batch logger stuff which is a pain to support. Surely every major installation must do this and I dont want to write a bit of logging software.
    Q) Is there a standard logger you all use? Do oracle provide one?
    Note I have already looked at log4plsq but this seems to rely on dbms output which I am not happy with as you can easily break the buffer limit.

    No I dont think so. I would have thought that all
    major batch processing systems have this requirement
    in general to write error/info/debug information to a
    file or table.True. Different applications may well have different requirements, however. Generic frameworks are great for logging unstructured information. Custom frameworks tend to be more useful when you need to log more structured information (i.e. writing exceptions to a table, logging application-specific status messages for monitoring, etc).
    I am aware of this approach but this does have a few
    limitations mainly :
    a)if the tablespace is full then you are unlikely to
    write to the tableTrue. However tablespaces filling up generally trigger pages to DBAs, so it's relatively unlikely that anything your application logs in this situation will be beneficial. I
    b)writing of to the table has to be handled
    independent of the commit strategy of the main
    program.Not if you use autonomous transactions
    c) we have requirement that this informaiton is
    written to a fileIt seems somewhat silly to me to log to a flat file from a database-- having error information in tables lets you query it much more efficiently than you can search a bunch of flat files. File I/O also tends to be quite expensive relative to table writes, which can really hurt batch processes. Log4PLSQL, however, does permit you to log to the alert log or to a database trace file.
    Justin
    Looks like APC beat me to it and covered the same points I did. Glad to see we generally agree.
    Message was edited by:
    Justin Cave

  • How to run the program for specified time

    Dear Friends,
    I have a small problem, I want to run my labview program for specified amount of time, Say for example it might be 1 hour or 5 hours or 10 minutes or even milliseconds(The time will be specified by the user).
    How to write programs for this
    And I want to get the system time in an instance, how it can be achieved,
    Could you please help me?
    Regards,
    Rathan

    Hi,
    Herewith my screenshot attached. There are thre inputs thres, tempX, xValue, it is in side the while loop.'xValue' will be acquired every iteration, It will be saved through shift register and acquired to 'tempX' for the next iteration, 'thres' is a constant value. I'm doing some logic, and calculating the dvalue and convert it to a string and concatenate it with end of line character, then after writing it into a file.
    In the logic, inside of the functional logic  I'm assigning some values dValue, if the logic is true or else dvalue will be 0
    What I require is I don't want to write the dValue in to a file, if it is equal to zero. Could you please help me, how to tackle this problem?
    Thanks.
    Regards,
    Rathan   
    Attachments:
    writing except 0.GIF ‏9 KB

  • Function modules and rfc

    please give me the code for writing exceptions in an rfc like bapiret2 to handle all type of exceptions ehile inserting or extracting data?

    Hi,
    Refer this link.
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCFESDE2/BCFESDE2.pdf
    It explains u in detail.
    Reward if helpful.
    regards,
    Ramya

  • Varchar2 "Width" during code execution

    Release 10g2 --
    Is it possible to in some way determine the defined "width" of a char variable (esp. varchar2) during code execution?
    For example, given:
    =================================
    strng VARCHAR2(<width>)
    BEGIN
    strng := function(sizeof(strng))
    =================================
    Is there any reasonably straightforward manner to create that "sizeof" function which can return the max width of strng to the function? I'd like to make sure, without writing exception logic, that I don't overflow the boundary of the strng variable. This is fairly easy to do in c but I don't see anything readily analogous in Oracle. Assume that strng is not tied to a table column, in particular, although that, too (i.e., created using %TYPE in the definition) would probably be useful to be determinable as well.
    Any suggestions as to how one might accomplish this without some absurd "fill until the exception occurs" loop would be appreciated.

    Thanks, I searched for something like that but didn't find it.
    There is a function called VSIZE in Oracle 9i, but it returns the memory length of the ACTUAL string, not the theoretical maximum. The only way I see for you is to select the string length from the data dictionary, look at ALL_TAB_COLUMNS. Or write a loop with an exception section, trying to add one character after another until the exception is raised. This is correct, VSIZE does not do what I'm after. The specific link above deals more with the special case of %TYPE. I'm more interested in the general case of a defined variable -- Where in the Data Dictionary would I look for information about a variable? (I don't necessarily need instructions, but a pointer to something to read that should cover what I'm after would be helpful-- even a book reference would be of use, since it's hard to tell what books cover what topics well -- I don't mind becoming more knowledgeable about the DD, that seems like widely useful info anyway).
    Any suggestions, links, pointers, would be greatly appreciated, thanks.

  • Cicso Jabber has encountered a problem and needs to close

                       I have 30+ users all intermittently getting the error while Jabber is running in the background..    We have Jabber set to start on boot, and it also sometimes will not load at boot and errors instead.  All PC's are running XP SPK3, with Office 2007 SPK3.  Any ideas?

    Hi Sandra
    I have the same problem.  Jabber client ver 9.0.5, XP SPK3.  My issue appears with Jabber set to start on boot and disappears when start on boot is disabled.  There's a button on the error dialog box which can be used to generate a logdump for TAC. 
    2012-10-14 07:38:49,546 DEBUG [0x00001528] [c\plugin-runtime\impl\JabberPrt.cpp(157)] [plugin-runtime] [topLevelRuntimeExpectionFilter] - Unhandled Jabber runtime exception has occured. Attempting to launch PRT.
    2012-10-14 07:38:49,546 DEBUG [0x000013b8] [c\plugin-runtime\impl\JabberPrt.cpp(157)] [plugin-runtime] [topLevelRuntimeExpectionFilter] - Unhandled Jabber runtime exception has occured. Attempting to launch PRT.
    2012-10-14 07:38:49,546 DEBUG [0x00001528] [rc\plugin-runtime\impl\JabberPrt.cpp(61)] [plugin-runtime] [InitalizePRTRelatedFilePaths] - PRT related files: Log: C:\Documents and Settings\me\Local Settings\Application Data\Cisco\Unified Communications\Jabber\CSF\Logs\csf-unified.log, Ini: C:\DOCUME~1\me\LOCALS~1\Temp\JabberPRT.ini
    2012-10-14 07:38:49,546 DEBUG [0x00001528] [c\plugin-runtime\impl\JabberPrt.cpp(124)] [plugin-runtime] [startJabberPrt] - Writing exception info and thread ID to .ini file.
    I just disabled autostart.  Thanks.  I thought it was just my PC..

  • Terrible customer service from Brendan at Telstra Bourke St Melbourne

    Hi All,
    Just thought I would ask your advice concerning repairs to my Iphone I requested from Telstra.
    The phone is great and I love it, my only problem is that it no longer turns on anymore.
    I took it to the shop where I bought it on (yep I lined up to buy it the day they were released ), the really flashy Telstra shop in the Bourke Street Mall. I got one of the techs on the front desk to look at it. He then took it to the head tech guy and he came back and said they would not repair or replace the phone under warranty. He said that it had a 'disturbed liquid submersion indicator at the bottom'.
    I have never droped it into water the whole time I have owned it, but I do travel overseas to humid areas so that may have set off the 'submersion indicator' to make the techs think that I dropped it into a puddle when I have never done that.
    Obviously, its a real pain, not having a phone for even a day, so I asked what my options were. I was told that the 'apple warranty is void and repair/exchange can not be carried out and the replacement cost for an 8gb for $670'.
    The quotes above are from what is typed on my Service Repair Order.
    I asked was it possible to send the phone to Apple to be inspected, and they advised that it was not, and that my only option was to purchase a new phone, and that I had two options. Firstly, if I surrendered my old phone, a replacement would be issued for $670. Secondly, I could simply purchase another iphone 'outright' for a cost of $726.
    I tool the second option, and have a brand new phone, although I am disapointed that I now have an almost new phone that simply stopped working that is now used as a paperweight.
    I tried everything to minimise the cost of getting a working iphone, and after talking to the lead tech, he then got the store manager to discuss my options.
    Brendan said he was the store manager, and eventually let me know his name after first stating 'I dont have to give you my name' and eventually told me his employee number was 0238895.
    He spent over an hour checking the situation while I waited, but would not put anything in writing except some notes in the section related to the 'reported problem' on the Service Repair Order.
    Is the advice that Brendan from Telstra gave me correct, and was it necessary for me to purchase another brand new handset for $726?
    If anyone has any questions I can be contacted on <Edited by: Host>
    Kind regards
    Wayne B

    See the response that I provided to Tamara regarding the recent change to the policy.
    You might want to print the new version of the policy and bring your receipt and go back to Telstra and see if they will consider an adjustment, i.e. you return your brand new iPhone, they swap it for a refurbished iPhone and credit you with the difference in price.
    I actually fail to see where you received "Terrible customer service from Brendan" as stated in your title.

  • Process does I/O, shows up on Disk Activity within Resource Monitor as System process

    I've written some software that performs a significant amount of file I/O. What is odd is that on Resource Monitor, I see the large amount of I/O being read/written to the files my process is writing --- except the process that is indicated under
    Disk Activity is the System process, not my process. My code is standard C++ (no direct calls to the Windows API), console mode. Can anyone explain why this occurs? Is this some artifact of console mode programs that I am stuck with? Thanks.

    Hi all, am intending to do some editing on me and my gf's pictures, and I need to assure her that it's not going to go onto the internet (she's extremely private).
    You could do whatever you need to do in Lightroom with the Internet unplugged, then your questions are moot

  • Apple Configurator - can't organize/group applied Apps?

    There is a ton of educational apps available, couple thousand looks like.
    So I'd like to download all the free ones (or at least as many as possible), and organize them into groups by subject matter in the iPad "App Launcher / Home Screen".
    Interactive Books
    Toddlers and Preschool
    Literacy Skills
    Reading Practice
    Handwriting
    Spelling
    Grammar
    Literature for K-8
    Literature for High School
    Poetry
    Vocabulary
    Writing
    Except there does not appear to be any way to do that.
    By default, the Apple Configurator slaps Apps onto the iPads as a huge unorganized mess.
    Is there some hidden functionality for grouping apps together and naming these groups in the Apple Configurator that I am just not seeing?

    And actually worse yet, Apps installed onto an iPad by the Apple Configurator are installed in an apparently totally random fashion.
    They look like this in the Apple Configurator:
    This is what they look like on an iPad 2, first use of the newly configured device:
    Apparently totally random icon (dis-)order.
    I have no idea why the Apple Configurator did that.

Maybe you are looking for

  • I can´t open Adobe Reader

    when I try to open Adobe Reader this messenge pops "Acrobat  has been closed unexpectedly " and so and so... I have Acrobat 9 and Im running on MacOsX 10.6.4 I also have installed the entire Adobe Suite CS5 ... I don´t what else would be important to

  • BIOS performance settings Slow- turbo

    I built my system with focuse on having good performance in games, and included 875P NEO as it was said to have good overclocking possibilies and good performance. System is : -P4 2.6 800 mhz northwood c -875p NEO with AmiBIOS 2.2,  Intel chipset (i8

  • How make a jCheckBox editable in a table with personal TableModel?

    Hi, first of all sorry about my English, ;) I made my own Table Model with this simple characteristics: - All rows isn't editables. - Backgound colors changed. - Get a Object[][] and Strin[] in his constructor. - Accept booleans type and put in the c

  • 39L4333DG - cannot display Flash content in web browser

    Hello, When I try to access Flash sites the web browser shows 'Missing plugin' in the frame where flash player should display the content. Am I omitting anything? I have installed the latest firmware: 7.1.90.34.01.1. For a 2013 TV it is annoying not

  • All warning messages are coming as an error message.

    Hi Experts, I am stuck in a problem where all the warning messages in my program are coming as an error message. if I define a message : MESSAGE 'HI' TYPE 'W'.  --> it gives an error msg instead of warning. Any clues......pls Thanks Rohit