Want to understand Exceptions

some basic questions regarding exceptions handling:
* I have some types of exceptions which are not code related but i want to handle them seperately. They include class instantion failure, could not get database connection etc. Their handling in all cases will be same (log it and send to Administrator). I was thinking about creating a seperate exception "InfrastructureFailureException" which will be thrown whenever such errors happens. But I am not sure this is a good idea. The reason is that in a logical-unit-of-work this type of exception can be thrown more than once. That means I have to use more than one try block. For example to get a Connection is a 2 step process:
try {
// get Connection Manager
} catch (InfrastructureFailureException ife) {
try {
// get Connection from Connection Manager
} catch (InfrastructureFailureException ife) {
Is there any better approach?
* i have defined a retrieve exception for each domain object, which is thrown by each retrieval operation. So I have a EmployeeNotFoundException which is thrown by getEmployeeById(int employeeId) DAO method. Similarly I have a DepartmenNotFoundException which is thrown by getDepartmentById(int deptId) DAO method.
Now I am thinking the above exceptions can be grouped as they belong to retrieve. So create a RetrieveFailedException and use it as a parent of the above exceptions. Is it a good idea?
I am also thinking about applying the same logic for INSERT and UPDATE (InsertFailedException and UpdateFailedException will be used as parents)
* Suppose an exception is thrown. I am having problems deciding which method to let handle this exception in the call stack.
Thanks

>>
However, for those who do develop applications,you
will either use a library (in which case it willbe
exceptionally relevant, pardon the pun). Or youwill
develop your own exceptions. Often I develop one for large applications.
Sometimes I develop one or two for a single layer.
Never more.
A library that does that is probably doing something
wrong.
An application that developes many is probably doing
something wrong as well. In my experience, that
happens because the developers are applying the
standards of library developement to application
developement.
Libraries are developed to serve the needs of
different users and with the intent that they will be
definitely be used in ways that the library
developers did not anticipate. Application are
developed to meet very specific guidelines. The
goals of both are different. Thus the goals and
functionality of each are different.
I agree. However, I make a distinction (see below) in types of exceptions. What the OP referred to are what I implement as 'unchecked' exceptions. These also seem to comport with your conception of an exception: that they
are truly exceptional. Truly exceptional circumstances are generally not recoverable. The unchecked data access framework of Spring is an excellent example of this. As these resembled the OP's original needs, I pointed out that library. In an actual application, I would use the library, customizing these exceptions to my own needs, or simply catching them in a front controller to display an error message to the user.
In either case, seeing
how an established library was constructed should
give you ideas on how your own exceptions might be
classified. I doubt it. Unless you are a library developer.
See above.
Data access exceptions are data access
exceptions. You may not need something asfull-blown
as Spring's data access exceptions, butundoubtedly
you will use at least a few.Yes - a few.
That having been said, in real applications, the
majority of important exceptions will be your
checked, business/model exceptions. Concentrateyour
efforts there. Worrying about whether I shoulduse
java.io.IOException or
com.foo.exception.NetworkException will distractyou
from the exceptions you actually need to write.In real applications, at least the ones that I have
worked on, exceptions are exactly that exceptions.
They are not anticipated, they are not expected and
d in normal operations they should never occur. They
do not need to be classified because any such
classification would suggest that they are
correctable when in reality, because they are
exceptions, they are not.
The customer help desk doesn't care whether the
database is down, or if there is a duplicate
insertion error, nor that the type specifier
definition is missing in a table. All of them means
that the customer service person can not do their job
and all mean that they have to call someone else who
will have to fix it. And to the person that fixes it
seperate exceptions will have gain no benifit if
there are multiple exceptions or one.
Exactly. This is why they are unchecked and intercepted only at a front controller level to display a generic error page to the user, and potentially issue a page for support or entry into a log file.
Additionally application developers often,
incorrectly, use exception hierarchies in such a way
that it completely destroys the information needed to
actually fix the problem in the first place, because
they end up throwing away the original exception
because they found a "better" one to return.However, I disagree with your notion of 'exceptional' exceptions. This is not in any way to say my way is 'correct', but rather to simply explain it.
Any time I read a business requirement that has an abnormal path of exceution (balance below zero, user account not found, accessing the flux capacitor on an even-numbered day of the month, etc.), I create a checked, business exception for that use case. It has an English-readable name, and any business user would be able to understand what that exception is for.
When developing the application, these exceptions ensure that all expected business exceptions are accounted for. It also reminds me of what abnormal paths of execution the business users have specified. Any business service should handle the possible business exceptions involved in a given call.
The remainder of exceptions are 'exceptional' exceptions. These I leave as unchecked. Sometimes I use a library or framework ala Spring, especially for data access or XML parsing or other general failure possibilities. Other times, when none are available, I create my own. However, they are always unchecked.
- Saish

Similar Messages

  • As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know each Java Class that is involved in flow.

    As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know how flows goes to the server and server understands the method which is to be called of managed bean. I know it is with annotation @ManagedBean and method name, but how Call is binded with annotation @ManagedBean.
    In short, i want to know the internal implementation of JSF Framework.

    As a JSF Developer, I want to understand technically how the JSF View Components are rendered as html and how there events are binded to Server.I want to know how flows goes to the server and server understands the method which is to be called of managed bean. I know it is with annotation @ManagedBean and method name, but how Call is binded with annotation @ManagedBean.
    In short, i want to know the internal implementation of JSF Framework.

  • I want to understand TJ command with array string

    In one of my pdf inside the stream i have this code:
    BT
    /F2 8.5 Tf
    1 0 0 -1 0 7.0295 Tm
    [IS, 12, B, 4, N: 978-1-449-32914-3] TJ
    0 -16.2 Td
    [[LS, 12, I]] TJ
    ET
    The Abobe text block display
    ISBN: 978-1-449-32914-3
    [LSI]
    I wanted to understand the significance of number inside [IS, 12, B, 4, N: 978-1-449-32914-3] , What does 12 and 4 stands for, where end result is ISBN: 978-1-449-32914-3

    This #pdfloc data is generated by RMSDK when user highlight (annotation) pdf and keep it in XML format in file system: E.g.
    <annotation y="-116" isvisible="False" x="-110" width="220" height="100">
            <dc:identifier>urn:uuid:DF061693-A668-49DF-A20B-DE243C463919</dc:identifier>
            <dc:date>2015-03-02T12:04:53Z</dc:date>
            <dc:creator>creator id</dc:creator>
            <dc:title>Page 4, 02-Mar-2015 5:34 pm</dc:title>
            <target>
                <fragment start="#pdfloc(7f54,3,37,0,0,0,0,1)" end="#pdfloc(7f54,3,37,3,1,0,1,1)">
                    <text>by Matt</text>
                </fragment>
            </target>
            <content>
                <dc:date>2015-03-02T12:04:53Z</dc:date>
                <text></text>
            </content>
    </annotation>

  • Some thing taht I want to understand in Css in ADF in panelTabbed

    I want to make style to panel tabbed when I hove a tab
    so I wrote
    af|panelTabbed::tab-content:hover{
      background-image: url("../img/tab1.png");
      vertical-align:          middle;
      text-align: center;
      width: 170px;
    }But this didn't work
    but When I used
    af|panelTabbed::tab:hover af|panelTabbed::tab-content{
      background-image: url("../img/tab1.png");
      vertical-align:          middle;
      text-align: center;
      width: 170px;
    }This worked with no problem
    but I want to understand this
    This line
    af|panelTabbed::tab-content:hover
    makes sense
    but this line
    af|panelTabbed::tab:hover af|panelTabbed::tab-content
    dont't make sense
    I want to understand this to be able to make my custom skin
    and what is the meaning of writing
    af|panelTabbed::tab:hover af|panelTabbed::tab-content
    without comma ","between them
    what this means

    This thread is a duplicate of {thread:id=2175114}

  • How works lync when I made a video conferences with someone in my same building?I want to understand how lyncs works, when I made video conferences with someone in my same building, if my call go to to server and then go to the person I´m calling. Or if L

    I want to understand how lyncs works, when I made video conferences with someone in my same building, if my call go to to server and then go to the person I´m calling.
    Or if Lync realizes that we are in the same building so it never leaves, so it don’t generate traffic. My concern is the bandwidth consumption.
    Please a I need the information.
    thanks

    In addition, you can refer to the following link about the media connection in different scenarios:
    http://www.shudnow.net/2010/12/06/lync-server-2010-port-ranges-and-audiomedia-negotiation/
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make
    sure that you completely understand the risk before retrieving any suggestions from the above link.
    Lisa Zheng
    TechNet Community Support

  • I want to understand how crypto works.

    Hi, I want to understand how crypto works and all. where i can start with. i really dont know anything about crypto. i need to understand how DC and keys and algorithims work together and how they work. pls suggest me where and with what i can start.

    Since you asked on the Java Cryptography forum, I would recommend beginning with this book:
    Beginning Cryptography with Java
    David Hook
    ISBN: 978-0-7645-9633-9
    http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764596330.html

  • Why the wait time!? Please? I want to understand.

    OK so why does it take so long to install apps on the iPhone and why so long to make a backup.
    Granted I have a ton of apps (like many i would imagine) But if they are mostly 1-3 MB and a few 10 MB why does it take soooooo long to install them?
    Secondly to do a back up of my iPhone it takes well over 2.5 hours for about a gig of apps. Syncing happens fast but backing up and installing are very painfully slow!
    I just want to understand why.
    I sync to a powerbook 17" 1.67Ghz with 2GB ram usuing iTunes 7.7.1 with a 1st gen iPhone running SW2.01

    If you are downloading apps on the iPhone it really depends if you are using 3G or Edge, or the WiFi network. It still going to take a bit of time because it downloads and unpackages the application right their. Lets say you downloaded 3 or 4 apps and added/changed a few contacts it's going to take longer. Otherwise we might need to wait for an update or sync every time you plug your iPhone in. You certainly have a good notebook, so it's definitely not your computer.

  • I want to understand Explain Plan

    Dear Gurus,
    I want learn/understand Explain Plan for query so as to tune the query.
    OR I want to tune query by understanding their plan but how it help to tune query.
    Could anybody give me link or material on above.
    Thanking in advance
    Sanjeev

    If you don't want to read the Oracle documentation, then this book is excellent: Troubleshooting Oracle Performance - Christian Antognini
    It does a great job of explaining execution plans.

  • I want to understand in which db I'm connected in bqy file

    I want to understand in which db I'm connected in bqy file, where I find the information,<BR> I'm not interesting the name of oce file, I want to know the name of the database,<BR> and if I use multiple connection, where this query is connected or this one<BR> <BR> thank you<BR> massimo

    Dear Barry,
    Maybe, I can explain you what I want:
    When I create 5 tabels on 2 pages, each tabel will have their own row numbers. When I'm working on page 2 and on row 40 for ex, it is very difficult to see which is row 40 of 1st tabel on page 1.
    When I put these 5 tabels in 1 big tabel, you won't have this problem, but than I can not name my tabels.
    So, I thought maybe I can link for ex, all row 40 in all 5 tabels

  • I want to understand The aironet Carrier Test

    Hi
    I want to understand how can i use the Carrier test result one the diagnodtic page of the aironet web interface for knowing which frequency is used or not
    thanks

    When doing the carrier busy test, it will show stars * in the different channels. These stars represent the traffic on that channel. The fewer stars on a channel the less traffic. http://www.cisco.com/warp/public/102/wlan/connectivity.html

  • New to Java Please, I want to understand..

    Hi,
    Here is what I am trying to do. I have a *.csv file that I want to put into an arraylist and the see the results on the screen. I get the code to compile but I don't understand the run-time error that is generated. Below is the code I am using plus the *.CSV and the run-time error:
    //The code
    import java.io.*;
    import java.util.*;
    public class File2Array {
        public static void main(String[] args) {
            File file = new File("persons_test.csv");
            ArrayList persons = (ArrayList) getPersons(file);
            for (Iterator i = persons.iterator(); i.hasNext(); ) {
                System.out.println(i.next());
        public static List getPersons(File file) {
            ArrayList persons = new ArrayList();
            try {
                BufferedReader buf = new BufferedReader(new FileReader(file));
                while (buf.ready()) {
                    String line = buf.readLine();
                    StringTokenizer tk = new StringTokenizer(line, ",");
                    ArrayList params = new ArrayList();
                    while (tk.hasMoreElements()) {
                        params.add(tk.nextToken());
                    Person p = new Person(
                            (String) params.get(0),
                            (String) params.get(1),
                            (String) params.get(2),
                            (String) params.get(3),
                            (String) params.get(4));
                    persons.add(p);                       
            } catch (IOException ioe) {
                System.err.println(ioe);
            return persons;
    class Person {
        private String ID;
        public Person(
            String ID,
            String LastName,
            String FirstName,
            String Phone,
            String Email) {
            this.ID = ID;
        public String toString() {
            return ID;
    }//The comma separated values
    *.CSV:
    ID, LastName, FirstName, Phone, Email
    2744, Avanto, Aldo, 562-593-6500, [email protected]
    1212, Dewy, Cheatem, 123-456-7890, [email protected]
    2345, yez, Wei do, 456-789-0123, [email protected]
    //The error
    Error:
    Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size:
    0
    at java.util.ArrayList.RangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at TryReadFileToArray_2.getPersons(TryReadFileToArray_2.java:25)
    at TryReadFileToArray_2.main(TryReadFileToArray_2.java:8)

    Both of the above 2 posts are right about the line breaks. I tried it and that caused the same exception message. Here is the modified relevant code which fixes that issue (solution suggested by jboeing). After this fix, I can have as many line breaks without any problem.
    while (buf.ready()) {
                        String line = buf.readLine();
                        if (!line.equals("")){ //NEW LINE ADDED
                             StringTokenizer tk = new StringTokenizer(line, ",");
                             ArrayList params = new ArrayList();
                             while (tk.hasMoreElements()) {
                                  params.add(tk.nextToken());
                             Person p = new Person(
                                       (String) params.get(0),
                                       (String) params.get(1),
                                       (String) params.get(2),
                                       (String) params.get(3),
                                       (String) params.get(4));
                             persons.add(p);      
                   }My java file and csv file is a copy/paste job from your first post. My CSV file does not have any line breaks at all. I used Eclipse3 for java. I also tried using Notepad/command prompt combo. Same output from both versions.

  • Getting a New MBP and Want to Understand CDs/DVDs

    Hello-
    this might be the wrong area bt I am sure I will hear if it is. If it is, I apologize in advance.
    I have never understood all the various kinds of CDs/DVds. One very specific question I have is trying to purchase the correct CD/DVD for making a copy of the Deluxe TechTool, songs, back-up docs (which I have never done but am planing on getting a really durable external drive to mostly send the back-ups to. On to the CDs at Costco and Best Buy I have not fond a sales person who can explain to be what all the various initials mean and which ones are the best to have for saving things and using the same CD for saving additional date of it is not full and if I want to be able to go back and erase some of the date and RW/R-write over it.
    the last CDs I purchased, I put a few songs on one and I could not put anything else. Maybe there is an article that focuses on this topic and explains all the various initials but I really need to learn this. Any help would be much appreciated. Also is there a difference in the sound of recorded music when burning music using a CD that I can keep using until it is full and if I want to make it so that I can't (or any of my brothers can't copy over what I have burned on to the CD?) Not sure if that makes sense. Is there a better quality CD that one would use for music only and when the CD is full I would be ale to do something so that this specific CD can't be used again when it is full, and I make it unusable if anybody tries to add or take away from it.
    In advance, thank you.

    Fortuny-
    I sent Verbatim an -mail. it was fairly long but they were so-so with it. They helped me some understanding their media storage types. Basically, they do not get into using the initials other companies use to tell if the CD or DVD will take on burn or transfer or multiple, if you can erase and use the CD over again, etc. It sounds like (at least for their CDs) their basic CD will take more than one burn of a song or transfer of some data and still just all them "CD-R."
    I have never backed up before and I would like to start doing that. When I started using computers and learned how to back-up, we were using CDs to back-up to. (Took a computer class my first year n college and it was MS-DOS. lol) I guess those days are over. Even the DVD and Zip disc are not used much for back-up anymore.
    So, I am thinking of getting a heavy-duty external drive that has some rubber added on the edges and can use USB 2.0 or FW 400 or 800. this is primarily for school (grad degree in architecture and planning)
    Do you get your Verbatim media from the website or at another store locally?
    You satisfied with the quality? (Obviously, but still would like to hear your opinion about that.) Have you used their Music CD (I forgot the exact name)
    Thanks again!

  • Want to understand committment mechanism in PR/PO when deleting PO items.

    Is there any documentation or help you can offer me to understand the commitment mechanism in PR (Purchase requistion) and PO (Purchase order)? We are working on SAP 4.6C and modules FI-FM and MM are implemented and working.
    Specifically I want to explain a case that urges me to understand and solve.
    An user wanted to delete a PO item which was derived from a corresponding item of a PR, but the system generated an error message indicating exceeded budget, it feels not logic because if I eliminate an item the corresponding budget amount should be available, not exceeded. However, I have been reading some SAP notes (955107, 1307755, 153021) indicating that in the availability calculus, the PR committment is considered and not the PO committment as expected by me.
    In the SAP notes I couldn't find the reason of this behavior.
    Is there anyone who experimented this kind of situation that can help me, please. If you need some clarifications or something else, please let me know.
    Thank you very much.

    Hi,
    please distinguish between POs/PRs with deletion indicator set and                
    deleted POs/PRs which do not exist on the data base (any more).
    The ones with deletion indicator can be corrected by the report RKANBU01, please see the note 534993. 
    For none existing POs/PRs please use the report ZKAOIDE0 from note 100409. For PR's you have to run CJEN afterwards. 
    Please read also the notes 334851, 152571, 863652 and    
    204376, 459509.     
    Regards,
    Edit

  • Want to ignore exception in a begin-end block

    Hi,
    For a given plsql block (inside a procedure or function for example) I want to ignore a certain oracle exception. Ignore as in, it should not be raised at all.
    What I want to do is something like this -
    begin (tell somehow to NOT raise NO Data Found (NDF) )
    bq. select &lt;something&gt; \\ into  &lt;some Variable&gt; \\ from &lt;somewhere&gt;; \\ if sql%rowcount = 0 \\ then \\ +&lt;take action meant for NDF&gt;;+ \\ end if;
    end;
    Any Ideas ?
    cheers
    raghav..

    Justin,
    If you have queries that can properly return 0 or more rows, that is the natural way to implement that. It won't raise an exception if no data is found, it won't raise an exception if multiple rows are found.How can I write a query that would not raise an exception when 0 rows are returned ?
    I'm not clear on how a design can "not like the NDF as such". Why would you have to convert that to a business exception and pass it along to the caller? Why wouldn't you just handle the exception in your code if you expect that the NO_DATA_FOUND exception is valid.
    The design doesnt like NDF just because the end user has to receive a better response than "No Data was found". We want to include lots of contextual info about the error and the location etc. Even though the NDF is valid, I wont pass it along as such, I would probably convert it to a business exception which would probably say something like "no entities found for end client <ID>" etc..
    cheers
    raghav..

  • Want to understand SID concept...

    Hello experts,
    why not using the value like e. g. customer number directly in the dimension table instead of a SID? So I also could save one table (SID table)  and with this on JOIN by linking directly to the master data tables (text, attributes, hierarchies) using customer no. as key.
    Am I wrong? Is it only because of this INT4 thing with the SIDs whitch maybe results in better performance?
    What I maybe understand is compounding, it seems to be hard to make here a connection to the right master data table. But if I wouldn't have this case, why else could be this SID useful?
    Best regards,
    Peter

    Hello Siggi,
    thank you for your answer and the linke you provided. I think star schema concept and using surrogate ID's for dimension tables is absolute clear for me and I see the advantage there.
    How I said, faster DB access using INT4 values instead of characters is also a point I understand. On the other side SAP BW offers you to use a line item dimension which saves a join and result in a better performance.
    But why not give the BW developers the chance to decide if you want use it? If your InfoObject is a numeric one, you are may be much faster, saving a join and having an even easier to handle value.
    What I am interested in is, if SID technology is so deeply part of SAP BW, for example if you want to report on an DSO you also need SID's, what is the real advantage usind SID's every time for access of InfoCube or DSO data?
    See, i read for example the following advantages of BW star schema on [this site|http://learnmysap.com/sap-bw/138-classic-and-sap-bw-star-schema-comparisons.html]:
    -> Faster access to data than via long alpha-numeric keys. SAP BW use automatically generated INT4 keys for SID and Dimension ID
    ->  Can model in easy way: Historizing, multi-lingual, and shared dimensions. It is happen because of the excavation of master data from the dimension tables using the SID technique.
    ->  The query performance is improved here as aggregated key figures can be stored in their own fact tables.
    OK, first point about INT4-keys we discussed.
    I completly don't understand the second point and why therefore SID's are needed.
    Third point depends on disadvantages of the classical star schema compared to bw aggregates, a point I understand
    Often I read: The SID table provides the link between the master data and the dimension tables. (like here: /people/githen.ronney3/blog/2008/02/13/modeling-strategies)
    But why shouldn't this be possible just with the key value?
    Even SAP just describes his enhanced star schema without SID's, but technically SID's are used. Why not use it like SAP itself describes here:
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/4c/89dc37c7f2d67ae10000009b38f889/content.htm
    regards,
    Peter

Maybe you are looking for

  • I am trying to connect my Macbook 4.1 Black to my Samsung UE50F6400 using a mini DVI to HDMI adaptor

    I bought the UE50F6400 samrt TV. It has 4 HDMI ports. HDMI 4 is HDMI/DVI, HDMI 3 is normal, HDMI 2 is (ARC) and HDMI 1 is (STB). reading the connection diagram it shows Laptops are to be plugged in to HDMI 4 (HDMI/DVI). But when I plug a HDMI cable i

  • CS5 document won't open

    I have a 55-page CS5 document that will not open. I sent it to our local IT help desk, with no luck. Of course, this goes to press tomorrow. I'm on a Mac. Any options out there?

  • Com.sapportals.wcm

    Hi, could somebody please send me a JAR file containing the IURLGeneratorServiceClass or or even better everything under com.sapportals.wcm.* to   [email protected] Best Regards

  • How to start with LACP on two SG 200-50?

    Hi, I've two SG 200-50 and I need to use LACP? What should I do? Adrian

  • APEX 2.2 output type

    to all APEX guru ... does apex 2.2 now support dynamic pdf output? can you link an apex application/output to a non-apex app that's built or run on the same technology (HTTP and MOD-PLSQL)? i'm asking this coz we have a web app that's been built usin