How to catch up Exception message?

i have a question while using try{ ... }catch{ ... } clauses. for when update, delete, databse, there might be error occurred. all to often i do not deal with the message, only if to check log when serious problem i have to find it out; but i hope to learn how if i am able to display message of my own while erro occurrs. for instance, when falling into SQLException, originaly i might just utilize
}catch(SQLException e){
e.printStackTrace();
is it possible for me to catch up message inside the printStackTrace that may happen while errors appearing? (or only down to catch{} clause be the last deadline that i am able to use? because i hope i am able to capture error code like ora-1234 and tranlate it into messages that user, who doesn't know too much about pc, can understand easily while reporting bug; and not just saying "we have problem here!")
that is, if 'A' situation popping out, i hope to direct it to error page with special message shown. so does the same error page with different message specified while 'B' situation found out!
any suggestions would be appreciated~
thanks in advice,

printStackTrace isn't obligatory. It's basically what you do with an exception when you don't have anything more specific to do with it.
You can certainly catch a specific exception at any level, including inside another try {} block.
Even having caught an exception you can decide that you don't want to handle it at this point in the code, and throw it again.
You might do:
try {
     try {
       ... statment which migh cause a particular database exception
        } catch(SQLException e) {
        if(e.getMessage().startsWith("ORA-1232")) {
          .. do somthing usefull
         } else
        throw e;   // the particular SQL exception was unexpected so go on and crash
   catch(Exception e) {
     e.printStackTrace();   // unexpected program failure

Similar Messages

  • How to catch ALL Exception in ONE TIME

    I'm explain my issue:
    I'm making a program with Class, Swing, Thread ...
    Then all action I do on my graphical application, I use a new thread, well
    I want to capture in my Startup programs, all unknow exception and then, I display it with a JOptionPane for example
    In fact, I want to do something like Eclipse, when it crash, I capture the error
    Could you help me ? Tell me the best way to do that ?
    This is an exemple
    FILE: Startup.java
    class Startup{
    public static main (String args[]){
    try{
    new Main();
    }catch(Throwable e){
    //Message d'erreur fenetre
    FILE: Main.java
    class Main{
    Main(){
    init_action();
    void init_action(){
    mybutton.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent e){
    Thread th=new Thread(){
    public void run(){
    int a = 1 / 0;
    th.start();
    Well, in this example I want to capture the Divide By 0, I use the Throwable Exeption, in order to be sure I catch all unknow exeption
    Then, a good job, is to put throws Throwable in all function
    but Thread, and ActionPerformed ... could not implement it
    How to put this exception and jump it to Startup Program ?

    I already do that, what can I do for improving capture ?
    That's impossible ... It will be a great idea to make a Redirection of Error to a Exception class in futur version
    For example, when an unknow error arrive, don't show it on console and crash ... but run a class redirector exception, and magic, it show you a beautiful error warning, and stop properly the programme ...
    I put an error class, and put try {] catch {} everywhere, and run my exception class,
    this class detect the error exception and run a properly beautiful and clear french message (I'm french :d)
    Well, If you have the BEST other idea, tell me, I read your message with a lot of regard
    see you soon
    bye

  • How to catch SQL Exceptions in JSP

    Hi,
    I wanted to know how do we catch the correct SQL return code in a JSP page ?
    Based on the return code I wanted to display customised Error messages.
    But I could'nt figure out a way to get the error message returned by the underlying DB2
    database.
    I am using Websphere Application Server and the backend database is DB2.

    The only way I am aware of is parsing the exception message/the call stack.

  • Catch RFC Exception message text

    Hi Experts,
    I am calling a RFC from WebDynpro using adaptive RFC Model.
    This RFC returns some Exception message along with the exception key from SAP R/3.
    Like this :
    MESSAGE e000(ztxx01) WITH 'this is exception message'
         RAISING table_not_available.
    Now when i am trying to fetch this data in WebDynpro using the following statement:
    msgmgr.reportException(ex.getLocalizedMessage(), false);
    msgmgr.reportException(ex.getMessage(), false);
    I can only see  TABLE_NOT_AVAILABLE .
    How can i fetch the exception message thrown by RFC?
    Regards,
    Ashish Shah

    Hi Ashish
    you can't get the RFC-Messages directly (as i know).
    You have to rebuild your
    ABAP-Program that the errors will be redirected as a table.
    There it gives a structure named 0_return (i don't know exactly) this is the standard table for outgoing error-messages.
    Marco

  • SOAP-XI-RFC sync without BPM scenario: How to catch timeout exception in PI

    Hi all
    I made a scenario where a Webservice request was placed via XI to RFC in CRM.
    This is all done without BPM.
    Now the request came up that I have to handle undhandled exceptions from RFC such as Fatal Error, Dump in CRM etc in PI so that customer can get the idea of what happend in the Backend rather PI failing in the monitoring. I did that in CRM by catching all the exception and sending a common error message to PI.
    But another requirement is to handle Message Timeout of the RFC in PI for e.g. If the request goes to the RFC and due to the volume of the data, it gets Timed Out then neither PI nor CRM can handle this and it results in PI failing to catch this excpetion.
    I tried Fault message type but that does not help either.
    Can I get some expert advice.
    Regards
    Naina

    Include your Send_to_RFC step inside a Block...have a deadline branch for this and an Exception Branch....in deadline branch have control step (thro Exception)....in Exception Branch have a Mapping and a Send Step....this mapping will produce a message (define separate DT for this) having constant values (like timeout occured message)
    If you are fine with alert message...then instead of Mapping and Send step in Exception include a Control Step (thro alert)....alert message can be "timeout occured in receiving RFC response"
    Regards,
    Abhishek.

  • How do catch SQL Exception

    I'm using oracle 8.1.7
    How do I catch a SQL Excpetion from a JSP page that is trying to delete a Primary key of a referencing table?
    When it throws the excpetion...how can I know the error code/number?
    or is it just simply give out the reason/explanation without producing any numbers?????

    Hi,
    Just put your conde inside a try - catch block like Servlets. It will work and show u all the things.
    Sundar

  • How to catch exception in JSP????

    how to catch exception in JSP?
    I use JDeveloper 3.1
    I use connection with database .
    When I insert record in database
    when have duplicate of primary key
    how to catch this exception and
    back to previous page?
    I trying with folowing:
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <% try {
    RowEditor.setUseJS(true);
    RowEditor.initialize(pageContext, "package2_Package2Module.Drzavi1View");
    RowEditor.setSubmitText("Save");
    RowEditor.setTargetUrl("Drzavi1View_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.render();
    catch(Exception e) {
    %>
    <script>
    alert("primary key duplication");
    history.back();
    </script>
    <% } %>
    but i't not working
    please help me

    i catch exceptions as you do, i don't have any problem...
    are you throwing the exception from your bean?
    actually i don't catch an Exception, but an SQLException...
    but it works... here is my code...
         try
    myclass.addElement(); // this is an insert into Oracle
    catch( DataBaseFailException e ) /// an exception that i throws inside after i receive an SQLException
              session.setAttribute("gMessage","e.getMessage()); // error code

  • How to use jsf2 exception handled

    hi,
    i'm a new to jsf2
    i want to catch the exception from action, and show it on a pop page, or alert the exception message in JS.
    but i don't know how to catch the exception from service(like action, ejb), and show it on client(like page or js).
    i'm try to user A4J.Ajax.onError (i use jsf 2 and richfaces4), but there is a js error A4J is not defined.
    please help~

    i'm try to user A4J.Ajax.onError (i use jsf 2 and richfaces4), but there is a js error A4J is not defined.Yes so you are doing it wrong and you need to read the manual. Fixing errors is a big part of your job you know, running to a forum the first hitch you get is not going to make you a valuable contribution to the software development market.
    http://www.jboss.org/richfaces/docs

  • Catching Converter Exceptions

    Hello! Anyone here have any idea or having the same problem on how to catch an exception from a DateTimeConverter object? It seems like a getAsObject() was performed before entering the validate action of a specific textfield which has a DateTimeConverter on it. I wanted to cutomize the message instead of the "Conversion error" that is appearing on my portlet.
    Thanks!!!

    Many Thanks Sakthi!!! how stupid of me!! I didn't see that it was on the tutorial hahaha been I've been looking for a reference for almost a day. anyway any idea also on how to catch an Exception form the validator when it is binded to a textfield? I've done it using a validator-method(event) but not when it is binded to a textfield is this possible?

  • Is there a report to track the exception messages after a MRP run ?

    We have a scenario at our client site where MRP run is not optimized to the fullest.
    The planners are not trained on how to interpret those exception messages.
    They are not trained on how to reschedule / expedite planned orders resulting from an MRP run.
    Is there a report out in SAP that keeps track of
    1) History of number of exception messages by type ( Expedite/Reschedule/Cancel)
    2) History of number of exception messages that were acted on or ignored by the planner.
    This is to create metrics on the usage of MRP exception reports by planners.
    Appreciate your inputs..

    Hi
    The exception messages are dynamic and time dependant. You cannot have history of exception message.. If your user is feeling difficult to use standard MRP reports. Create a new report using a function module MD_STOCK_REQUIREMENTS_LIST_API
    It gives all MRP data including exception messages.
    Regards
    Antony

  • Abstract asynchronous message interface for fault (exception) messages

    Hi,
    Has anyone yet discovered how to create an abstract asynchronous message interface for a fault message so that said message can be referenced in an Integration Process? I am currently at a loss as to how to reference the exception message returned by a synchronous RFC call, and how to return the fault message of a synchronous MI from a BPM.
    Thanks for any help you can provide on this issue - please do not refer me to existing blogs or forum messages if they do not specifically answer this question in a positive manner. I have just been through the SAP Notes and the SDN forum and Google and while I have seen many questions about this topic I have not seen any answers. 
    Stephen

    hi stephen,
    never worked on this but out ofcuriosity after seeing ur question i tried to  create one:
    but i found these:
    fault message types will only be used in case of synchronous messages.....if it is asynchronous the fault message type radio button it self will not seen while creating message interface..just check.
    you need to create a Fault message type to use it in an interface...u can add your own fields also if u want.
    in your present case you mentioned you are using synchronous RFC...try creating a synchronous abstract interface there you can give fault message type also...just check by creating one...
    correct me if i am wrong...
    regards.

  • How to use customized exception

    Hi all,
    I have a problem using struts-action-mappings.
    I have a method for update in my app module, and i'm using that method with data action.
    In that method, I have to throw my customized exception to user if there is error. I just don't know how to catch the exception and display it in page.
    I've read about struts page flow diagram elements and know there are Exceptions and Global Exceptions. But i still don't know how to use them.
    What i want to know is can I relate my custom exception with Exceptions/Global Exceptions in struts diagram? And if so, can anybody show me an example for it?
    Thanks

    1.Create a method GET_ACTORS using RH_GET_ACTORS,
    2.Create a container element 'Actors' type string with multiline.
    3.Create Task, where you can call the Method GET_ACTORS  and pass the Container values of 'Actors' from Method->Task->Workflow
    4.Create a Step type before creating the Step mail and include the previous Task.
    5.Now you can create the step Mail. Give the Recipient Type as 'Expression'-> Select the Container Element 'Actors' from WF container
    But remember the values should be Passed from the task to Workflow in Binding correctly.
    Regards,
    Sriyash

  • Sorting exceptional messages in md06

    Is it possible to sort according to exceptional message numbers in md06. i have got more message no. 20, i like to sort and delete the same. pls advise how to do that?

    YS,
    I don't know how to delete an exception message.  I can't imagine why you would want to delete an exception message.  They will simply be recreated on the next MRP run until you fix the underlying problem.
    I DO know how to filter the output such that all 'non-20-message-type-materials' are highlighted in the results screen.  Then you can scroll from material to material to see each MD05 screen which contains the offending plans. 
    MD06>select the message groups that you wish to display.  I personally like to see 6 and 7.  Instructions were kindly provided in a previous response by Rammohan and Sankaran.
    On the next screen, you will see the list of materials which contain the messages you had selected.  Now, hit CTRL-F or clik on the binoculars.  If it is a big list, you will get a popup, clik through.
    Now you are on the 'Find' popup.  select the "Find Exceptions" tab.  You will see a statistical listing of all the exception messages summarized.  Select all but '20', hit the green check.
    All materials will be displayed that don't have a 20 message.  Hit F5 or clik on the glasses(display MRP list).  You will be taken to the first MD05 that was highlighted.  Fix the problem as necessary.  Now hit CTRL-F2 or clik on the small right arrow on the Icon bar.  This will take you to the next MD05.  Continue until done.
    Regards,
    DB49

  • Creation of Exceptional messages

    Dear All,
    In the Stock/Requirements list, I want to create an exceptional message for the following Stock Transport scenario.
    Supplying plant is 1000, Receiving Plant is 1100.
    In the Receiving Plant 1100 there is a Stock transport PO with Receipt Date 01.06.09.
    For the the same PO, there is an MRP element 'Ord DS' in the supplying plant 1000 with Requirement date 01.06.2009.
    Since the Requirement date is in the past at the supplying plant 1000, system should give an exceptional message .
    Please guide me how to generate the exceptional message.
    Thanks & Regards
    Bala

    Hi
    Steps to create Exceptional massages
    1) Define  Check Exception Group Texts : using path  SPRO > Production > Material Requirements Planning > Evaluation > Exception Messages
    2) Create new messages in Table T458A (Exception Messages in Material Requirements Planning) and Set Priority for EM
    3) Check the Messages in SPRO >  Define and Group Exception Messages
    Regards
    Brahmaji

  • Catch multiple exceptions ?

    hi,
    can some1 tell me how to catch multiple exception like this :
    try
    catch (IOException e, NullPointerException ne, customizedException me)
    is it possible ?

    try this way.......
    try{
    catch(IOException e)
    catch(Exception ee)
    and take care of the order of the exceptions being thrown.( Exception of lowest order shoulh be caught first)
    hope this helps
    regards
    harpreet

Maybe you are looking for

  • My new iphone 5s wont synch with itunes but my new ipod does

    My new iphone 5s will not sync with itunes on my windows computer but my ipod will sync ok. I have deleted and reloaded itunes on my computer and have sone a restart on the iphone. Any ideas ?

  • Can't edit or delete some photos

    iPhoto has got me scratching my head. I've got a few photos that I can't edit or delete. I ran the iPhoto permission, library, and thumbnail rebuilds without any success. I looked at the file permissions and I have r/w. One odd thing is that I can se

  • Need a little help with strings

    So I would like to have the user input a month by using the abbreviation ex. (mar or apr) instead. So I want month to be a string right? When I tried that I get an error. What should this look like? import java.util.*; public class MonthSwitch   stat

  • HT4623 netflix is saying i need ios6 to play on my ipad 1, but the ipad only offers ios5.1.1

    Hi, Netflix is asking for ios 6 or later and my ipad is only up to ios5.1.1

  • IPod Nano continuously Syncs

    New Nano (Christmas present).  Has been working fine (and still does) but now seems to display that is continuously is syncing with iTunes when ever it is plugged in.  I plug it into my computer.  iTunes is open.  The Nano is recognized and then it b