Generalised Event Exception Handler

Hi all experts,
Can anybody plz tell how to create a generalised Exception Handler , so that wenever a exception is generated in the main method the Exception Event Handler shud be initialised to catch the exception for all the exceptions generated at runtime.
I want the Exception Event Handler to catch the exceptions for RFC BAPI,EJB Webservice,etc..as i am using this in my application to give general message at runtime if any exceptions is generated from the try-catch block.
Waiting for the reply.
Regards:
SK

Hi SK,
There is a general Exception that you can use for all exceptions thrown.
just add this code for any exception you want to catch.
try
    // try anything
catch(Exception e)
   // catch any exception
Regards,
Marshall.

Similar Messages

  • Use bridgeTalk with onError event, exception handling

    Hi all,
    I'm writting a function who use bridgeTalk to execute a photoshop script. This function works but I would like to throw an exception if the script has a problem. I commented a line in my script to have an exception but the onError event doesn't throw my Error.
    Have someone an idea?
    Thanks!
    function save_to_PSD(obj){
        var bt = new BridgeTalk();
         bt.target = "photoshop";
         bt.body = save_to_psd_function.toSource()+"("+obj.toSource()+");";
         bt.onError = function(errObj) {
            // the next line display the error in the console
            $.writeln(errObj.body);
            // PROBLEM this error is never throw
            throw new Error (errObj.body);
         bt.send(100);
    function save_to_psd_function(serializedObject){
        app.displayDialogs = DialogModes.NO;
        var obj = eval(serializedObject);
        var file_path = decodeURI(obj.file_path);
        // this will generate an exception
        //var img_file = new File(file_path);
        var ps_doc = app.open(img_file);
        psdSaveOption = new PhotoshopSaveOptions();
        psdSaveOption.embedColorProfile = true;
        app.activeDocument.saveAs(img_file, psdSaveOption, true, Extension.LOWERCASE);
        ps_doc.close();
        app.displayDialogs = DialogModes.ALL;

    Hi all,
    I found this solution if it can be helpfull for someone.
    But I don't know if it is the better way. I'm not abable to run a new exception in the onResult function.
    function save_to_PSD(obj){
        var error = null;
        var bt = new BridgeTalk();
         bt.target = "photoshop";
         bt.body = save_to_psd_function.toSource()+"("+obj.toSource()+");";
         bt.onError = function(ex){
            error = ex.body
         bt.send(100);
         if(error != null){
            throw new Error(error);

  • Implementing Exception Handling Application Block in custom web parts, event receivers

    hi,
      I am currently implementing try {} catch(Exception expp) { throw expp;} to handle exceptions in my intranet appln.
    I have several custom web parts, event receivers, few console applciations as timer jobs etc. If i want to implement a  robust exception handling what should be  the approach. by searching, i saw, ms patterns n practices provides the
    appln blocks.
    But I think[ pls correct me if i am wrong ] those  appln blocks are meant for asp.net applns ONLY.
    if not, anyone has implemented those appln blocks in SP development? if yes, can anyone provide one sample /  link to implement Exception Handling in SP.
    help is appreciated! 

    Hi,
    Here are some articles for your reference:
    Handling Error Centrally in a SharePoint Application
    http://www.codeproject.com/Articles/26236/Handling-Error-Centrally-in-a-SharePoint-Applicati
    Using Microsoft Enterprise Library Application Block in SharePoint
    http://www.codeproject.com/Articles/21389/Using-Microsoft-Enterprise-Library-Application-Blo
    Exception Handling in SharePoint
    http://spmatt.wordpress.com/2012/02/01/exception-handling-in-sharepoint/
    Best Regards
    Dennis Guo
    TechNet Community Support

  • Resume process instance after exception handling with an event subprocess

    We have a process with several automatic activities so we implement an event-based subprocess to catch any exception that occurs in the process.
    Since the error event is an interrupting event, how could we control the exception and resume the process where it was?
    BPM version 11.1.1.7
    Any suggestion?
    Thank you

    Know this isn't the answer you are looking for, but the answer to this gets much better in 12c where you can go back into the process after catching an exception in an event subprocess.
    In 11g however, once you catch an exception in an event subprocess you cannot go back where you left off in the main process.
    These are not great options I know, but here are a couple things I've seen to work around this:
    Exception error events in event subprocesses are always interrupting so one solution would be to instead use boundary events on the individual activities where the exceptions will occur.  Know you know this, but the down side of this is that it makes your process incredibly cluttered with boundary events.
    Catch the error in the event subprocess -> handle the cause of the exception -> exit the process -> invoke the process again.  The problem with this is that you would not be starting where you left off and where the error occurred.  You could work around this by having an exclusive gateway that directed it to the right activity in the process.
    Dan

  • Exception event subprocess handling

    We have a question around an exception event subprocess. In reading Oracle Fusion Middleware Modeling and Implementation Guide for Oracle Business Process Management 11g Release 1 (11.1.1.5.0) it indicates in section 19.5.6 that we can catch all system exceptions. Earlier in that section 19.4.1 point 4, second bullet point, it states “(w)hen the instance completes the exception handling flow, the process ends.” Our question is does the instance just end in the exception subprocess or does it route back to the task that threw the exception?
    We would like to have events throw an exception into the exception subprocess and after the subprocess ends route back to the task that threw the exception. In 10g this was the case and we are checking to see if that is true in 11g or how we need to handle this scenario.

    I do not understand your response. I have an event subprocess that catches all system and business errors. Then in that process I have a (Start Catch Error)->(user activity) ->??? What do I put as my end event? If I put a message end it is asking for the start message, which I don't have. What I want is when the admin had fixed the error, and they click accept/ok and submit, I want the instance to go back to where the error happened. For example, I have a sales quote process like this: (start)->(user activity)->(service activity)->(user activity)->(end). And for sake of this example my service activity does a database lookup, but the database is down so a system error is generated. So in this case my event subprocess catches the error and the admin fixes the error and submits. How do I get the instance to go back to my service activity. And yes in this simple case a i would have used a boundary event but for the sake of this example assume I have say 50 service activities and I don't want to put a boundary even on each one.
    Thoughts/suggestions?

  • Exception handling for Scanner console input

    I'm trying to add exception handling to a Scanner console to deal with exceptions caused by non-numeric input. My idea was to do use a try/catch in a for loop and break if no exception occurs.
    Whats happening is the "iNumber = console.nextInt(); " does nothing on subsequent retries, when an exception occurs. That is, I enter "123w", an InputMismatchException occurs, goes into the first catch block, hits "continue" and goes back into the for loop, hits the "iNumber = console.nextInt(); ", then immediately blows through it without executing. Thus, I hit my max loop count and exit with iNumber = 0.
    I'm thinking I may need to instantiate "static Scanner console = new Scanner(System.in);" again in the event of an exception?
    Thanks for any feedback. I'm brand new at Java and learning as fast as I can :)
    Here is the code:
    class ConsoleInput
         public ConsoleInput() // constructor
         static Scanner console = new Scanner(System.in);
         public int GetInput()
              int iNumber = 0;
              for(int i=0; i<3; i++)
              try
                   System.out.print("Please enter a number: ");
                   iNumber = console.nextInt(); // get console input
                   break;
              catch(java.util.InputMismatchException ex)
                   continue;
              catch(Exception ex)
                   continue;
         return iNumber;
    }

    public class Scratch {
      public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean gotAValidInt = false;
        int theInt;
        System.out.println("Enter an int");
        do {
          try {
            theInt = sc.nextInt();
            gotAValidInt = true;
          catch (InputMismatchException exc) {
            System.out.println("Not an int. Try again.");
            sc.next(); // consume the non-int that nextInt couldn't consume
        } while (!gotAValidInt);
    }There are different ways you could structure your loop, but the key is that when nextInt throws an exception, you have to call next() in the catch block to consume the token that nextInt couldn't.
    Edited by: jverd on May 2, 2008 1:52 PM

  • Exception handling in CE Visual Composer 7.1

    Hi,
    I have modeled a CAF Business Object and a custom Find operation which looks for a custom key. After that, I have exposed that operation as Web service and consumed it in Visual Composer. It is working perfectly as long as the search key exists in the Business Object backend table. When an arbitrart search term e.g. 1234 which does not exist is given, an error message is displayed and the program logic is halted.
    Error occured while executing the service: Error in connection: Could not execute Web service, consult your administrator
    My requirement is that, is it possible for me to display a custom message such as "The ID does not exist. Please enter a valid ID".
    Besides, is it possbile to bypass this service call if it is not working? In my scenario, this service is actually used to search for any existing data for a selected Customer. If there is no data, the user can proceed with a new definition. So, the above mentioned exception blocks the program flow and the user is not able to continue.
    Thanks in advance for any suggestions or ideas.
    Regards,
    Joon Meng

    I am not aware exception handling features of VC but instead of raising SOAP Fault you can also transfer log message which is user friendly to display.
    Another thing, instead of throwing exeption handle it inside try block so that program do not halt abruptly but gracefully. It is always possible to bypass existing service call like you said if output of service is not input of another.
    In other word do not map output directly but on the "Next" event of button which enable you to goto next screen to work.
    Regards,
    Gourav

  • Exception handling in IDOC using workflows

    exeception handling in idoc using workflows
    i. what will be the trigerring event in case of idoc ?
    ii.will it be BOR -- IDOC<message_type >?
    thanks in advance
    naval bhatt

    Hi Naval Bhatt,
    it depends on what you would like to do, but there is an object IDOCAPPL, more information you find Objekttyp IDOC<MSGTYP>:
    http://help.sap.com/saphelp_47x200/helpdata/en/04/92725546f311d189470000e829fbbd/frameset.htm
    General how it works:
    Objects, Events and Tasks to be Created
    http://help.sap.com/saphelp_47x200/helpdata/en/78/2176d251ce11d189570000e829fbbd/frameset.htm
    This is an example how the application should implement the exception handling in IDOC by using workflows.
    Events for example:
    - inputErrorOccurred
    - inputFinished
    Regards
    Tibor

  • Bounded Taskflow Exception Handler not working with Page Fragements

    I have one bounded - taskflow task-flow-definition
    <?xml version="1.0" encoding="windows-1252" ?>
    <adfc-config xmlns="http://xmlns.oracle.com/adf/controller" version="1.2">
      <task-flow-definition id="task-flow-definition">
        <default-activity>view1</default-activity>
        <managed-bean>
          <managed-bean-name>backing_main</managed-bean-name>
          <managed-bean-class>view.backing.Main</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <managed-bean>
          <managed-bean-name>backing_view1</managed-bean-name>
          <managed-bean-class>view.backing.View1</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <managed-bean>
          <managed-bean-name>backing_view2</managed-bean-name>
          <managed-bean-class>view.backing.View2</managed-bean-class>
          <managed-bean-scope>pageFlow</managed-bean-scope>
        </managed-bean>
        <exception-handler>view2</exception-handler>
        <view id="view1">
          <page>/view1.jsff</page>
        </view>
        <view id="view2">
          <page>/view2.jsff</page>
        </view>
        <use-page-fragments/>
      </task-flow-definition>
    </adfc-config>view1.jsff contains one command button, which calls one ActionListener
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:commandButton text="commandButton 1" actionListener="#{pageFlowScope.backing_view1.callMyFunction}"
                        binding="#{pageFlowScope.backing_view1.commandButton1}"
                        id="commandButton1"/>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_view1-->
    </jsp:root>view1.java callMyFunction throws an Exception
        public void callMyFunction(ActionEvent event) throws Exception{
            throw new Exception();
        }view2.jsff is an exception handler
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <af:activeOutputText value="Exception Occured"
                           binding="#{pageFlowScope.backing_view2.activeOutputText1}"
                           id="activeOutputText1"
                           inlineStyle="font-size:xx-large; color:red;"/>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_view2-->
    </jsp:root>above taskflow is dragged-drop as a Region in one file main.jspx
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=windows-1252"/>
      <f:view>
        <af:document binding="#{pageFlowScope.backing_main.document1}"
                     id="document1">
          <af:form binding="#{pageFlowScope.backing_main.form1}" id="form1">
            <af:region value="#{bindings.taskflowdefinition1.regionModel}"
                       id="taskf1"
                       binding="#{pageFlowScope.backing_main.taskf1}"/>
          </af:form>
        </af:document>
      </f:view>
      <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_main-->
    </jsp:root>*pressing a commandButton on view1.jsff throws an Exception as expected but does not go to exceptionHandler [view2.jsff]*
    However, this does work with Bounded Task-Flow without page fragments , view1.jspx contains one button, calling one method which throws an Exception,
    view2.jspx is an Exception Handler, and in this case it redirects to the view2.jspx [error page]
    any ideas?
    thanks

    Hi,
    Pretty much. However, you got the event part wrong, which is mostly my fault here. First, let put down some general JSF facts about event handling.
    1. http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIComponent.html#queueEvent(javax.faces.event.FacesEvent)
    2. So, basically, queuing an event on a component means queuing it on its parent until you reach the UIViewRoot that will really actually queue it. That strategy allows iterating components to intercept event queued on their children to record the row index as well so that the data model can be synchronized correctly during the broadcast phase (see http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIData.html#queueEvent(javax.faces.event.FacesEvent) and http://java.sun.com/javaee/5/docs/api/javax/faces/component/UIData.html#broadcast(javax.faces.event.FacesEvent))
    3. Exceptions that aren't handled by the exception handler are thrown during broadcast or various process* methods.
    So, the catch component must leverage these facts to intercept events queued on its children (by overriding queueEvent method) wrapping the original event in a custom on that flag the catch component itself as the source of the event. The result will be that the broadcast method of the catch component will be called to handle the event. The broadcast method must then unwrap the event (to get the original event), gets the original source, then call originalSource.broadcast(originalEvent) within a try-catch block.
    Does it make any more sense put that way? Note that it's an obscure part of JSF so I cannot make it incredibly simple either.
    Regards,
    ~ Simon

  • Never implemented exception handling  in Stored Procedures

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

    I have lots of stand alone stored procedures callled from .NET 20 programs that follow the following pattern. They runn against Oracle 10.2 on Win2003. The only deviiation is a couple where I insert to temptables. I specify a parameter for messages but don't know the best way to implement for Oracle as well as any tips on ODP.NET/oracle interactions error handling.
    1. Is it recommended to implement exception handling in With Clauses?
    2. If there is an exception in one cursor's SQL, how do I still execute the second?
    3. Is it best in some circumstances to pass a null back to client and check for null in program?
    From .NET programs I have run into a couple of problems.
    4. TNS packet failure.
    Anyways any suggestions or experiences are welcome.
    CREATE OR REPLACE  PROCEDURE   GET_SALES_DATA
                      ,   p_businessdate      in   date                 
                      ,   p_message         out varchar2     
                      ,   p_rcSales             out sys_refcursor
                      ,   p_rInventory            out sys_refcursor
    ) is
    open p_rcSales for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    open p_rcInventory for
    with somedata as (select ...)
    , someMoreData as (selct ...)
    -- Main select
    Select * from somedata sd inner join somemoredata  smd on smd.key   = sd.key;
    -- CODE NOT IMPLEMENTED
    -- exception 
    -- when TOO_MANY_ROWS  then  select 'Error handling for future implementations' into p_message from dual ;
    -- when NO_DATA_FOUND  then  select 'Error handling for future implementations. No data'  into p_message from dual;
    -- when others         then  raise_application_error(-20011,'Unknown Exception in GET_SALES_DATA Function');
    -- WHEN invalid_business_date then  select 'Invalid: Business date is in the current work week.' into p_message from dual ;
    END GET_SALES_DATA;Pseudocode'ish because Module level variables and properties have not been defined here for brevity.
    Public Class WebPage1
    PAge_Load
       GetData
    End Class Data Access Layer
    Public Class DAL
    Public Sub GetOracleData()
                Dim conn As OracleConnection
                    Try
                        conn = New OracleConnection
                    Catch ex As Exception
                        Throw ex
                    End Try
                    Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rc_inven_csv", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    Catch ex As OracleException
                        HandleError("Exception Retrieving Oracle Data", ex, MethodInfo.GetCurrentMethod.Name, True)
                     Finally
                        If conn.State = ConnectionState.Open Then
                            conn.Close()
                        End If
                    End Try
                    dbMessages = cmd.Parameters("p_message").ToString
                End If
                arrStatusMessages.Add("Retrieved Oracle Data Successfully")
            End Sub
           ' Original Implementation ; No longer used
            Public function GetOracleData
               Dim conn As New OracleConnection
                conn.ConnectionString = dbconn.Connectionstring
                 Dim cmd As New OracleCommand
                    With cmd
                        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings("MyConnectionString").ToString
                        cmd.CommandText = DATABASE.GetSalesData
                        cmd.CommandType = CommandType.StoredProcedure
                        cmd.Connection = conn
                    End With
                    cmd.Connection = conn
                    Dim oparam As OracleParameter
                    oparam = cmd.Parameters.Add("p_businessdate", OracleDbType.Date)
                    oparam.Value = BusinessDate.ToString("dd-MMM-yy")
                    oparam = cmd.Parameters.Add("p_message", OracleDbType.Varchar2, ParameterDirection.Output)
                                 oparam = cmd.Parameters.Add("p_rcSales", OracleDbType.RefCursor, ParameterDirection.Output)
                    oparam = cmd.Parameters.Add("p_rcInventory", OracleDbType.RefCursor, ParameterDirection.Output)
                    Dim Adapter As New OracleDataAdapter(cmd)
                    Try
                        Adapter.TableMappings.Add("Table", Sales)
                        Adapter.TableMappings.Add("Table1", Inventory)              
                        Adapter.Fill(dsOracleData)
                    dim dt as datatable = dsoracledata.tables("sales")
                    If IsDataNull(dt) Then
                         _errorType = DBErrorType.NullData
                    End If
                    If isDataEmpty(dt) Then
                         _errorType = DBErrorType.EmptyData
                    End If
                    _hasError = False
                Catch oraEx As OracleException
                      _ExceptionText = oraEx.Message.ToString
                    _errorType = DBErrorType.OracleException
    #If DEBUG Then
                    Throw oraEx
    #End If
                Catch zeroEx As DivideByZeroException
                    _ExceptionText = zeroEx.Message.ToString
                    _errorType = DBErrorType.DivideByZeroException
    #If DEBUG Then
                    Throw zeroEx
    #End If
                Catch oflowEx As OverflowException
                    _ExceptionText = oflowEx.Message.ToString
                    _errorType = DBErrorType.OverflowException
    #If DEBUG Then
                    Throw oflowEx
    #End If
                Catch argEx As InsufficientMemoryException
                    _ExceptionText = argEx.Message.ToString
                    _errorType = DBErrorType.InsufficientMemoryException
    #If DEBUG Then
                    Throw argEx
    #End If
                Catch nomemEx As OutOfMemoryException
                    _ExceptionText = nomemEx.Message.ToString
                    _errorType = DBErrorType.OutOfMemoryException
    #If DEBUG Then
                    Throw nomemEx
    #End If
                Catch Ex As Exception
                    _ExceptionText = Ex.Message.ToString
                    _errorType = DBErrorType.GenericException
    #If DEBUG Then
                    Throw Ex
    #End If
                Finally
                    If conn.State = ConnectionState.Open Then
                        conn.Close()
                    End If
                End Try
    End class Error Class
    Public Class Errors
           Public Sub ExitClass()
                Return
            End Sub
            ' 'blnWriteNow says when Error is critical and no further processing needs to be done by class, then write to event logs or text files and call exit class
            '  to return control back to webpage. This is my first time trying this way.
            Public Sub HandleError(ByVal friendlyMsg As String, ByVal objEx As Exception, ByVal methodInfo As String, Optional ByVal blnWriteNow As Boolean = False)
                If Not blnWriteNow Then Exit Sub
                Dim strMessages As String
                strMessages = arrStatusMessages
                'Send error email
                If  blnSendEmails Then
                     SendMail("[email protected],  strMessages. applicationname, " has thrown  error. ")
                End If
              'Throw error for   debugging
                If  blnThrowErrors Then  
                            Throw New Exception(strMessages & vbCrLf & objEx.Message)
                End If
               ' Write to event log and if not available (shared hosting environment), write to text log
                If blnWriteNow Then
                    If  blnWriteToEvtLog Then
                        If  blnCanWriteToEvtLog Then    'Program has write permission to log
                             WriteToEventLog(strMessages, _appname, EventLogEntryType.Error,  appname)
                        Else
                            If Not Directory.Exists( appPath & "\log") Then
                                Try
                                    Directory.CreateDirectory( appPath & "\log")
                                Catch ex As Exception
                                    arrStatusMessages.Add("Cant't write to event log or create a directory")
                                End Try
                            End If
                        End If
                    End If
                End If          
            End Sub
    End Class

  • General Exception Handling

    Hello. In my applications I usually have a try catch(Throwable) block surrounding all the top code (the code in main()) to log and report errors and exceptions that is not caught anywhere else, and to have my application exit in a controlled way. But I recently noticed that exceptions thrown in event handling (i.e. java.awt.EventDispatchThread.run) are not caught by the try catch block in main().
    Are there any easy way to catch everything so my app can exit in a controlled way?
    If this is not possible which exceptions are not propagated to main()? I would guess that it's exceptions thrown in other threads, is this correct? If so, do I have to surround all event handling by try catch(Throwable) to be safe?
    I would like more information and guidelines about exception handling. Any book recommendations?
    Help appreciated, thanks!

    You should never let exceptions propagate outside your event handling methods.
    If you don't follow that rule, the java.awt.EventDispatchThread.run() method terminates and the Java Virtual Machine tries to print the stack trace to the terminal window (if there is one) and then exits, but not through your main() method.
    So, try /catch all Exceptions inside your event handler methods:
    // inside event handler method
    try {
        // handle event here
       } catch (Throwable t) {
         // handle errors and recover from errors here
         // and either log error or if important display message to the user.
       }There is no easy-lazy way to do exception handling by only having the try/catch block in main in this case.
    Note : If any of the listeners throws an exception none of the following listeners is called. Since there is no guarantee of the order in which listeners are called you cannot be sure which ones are called first.

  • Exception Handling & Error Recovery

    Does the Pre8 Development Team plan to release a version that can recover from exceptions & retry problematic clips on long movie builds?
    Many hours spent multiple times to find an unrecoverable error has terminated a movie build is getting to me - not to mention unexpected crashes.
    It would seem the process could be setting recovery points to go back to in the event of an exception so happily conformed and rendered parts do not have to be continually rebuilt. The exception handling could be hierarchical, with local level retries a number of times, then if that fails, going back to a well defined restart point. Even media reloads could be accommodated, happily conformed clips could be cached, and even spare copies put aside.
    The number of unspecified errors indicates that not a great deal of care has gone into the exception hadling scheme to date.
    More meaningful messages might help users - for example, say a particular clip took many gos to fully conform, it is likely quite flakey and then the advice might be that it should be reloaded or even remade...
    The dumps after crashes clearly do not yet include the stack of recent actions that are used to undo things - maybe they should.
    The name of a media clip in hand, what the latest action is aiming to do with it (say add a particular effect), should all be reported in plain text and also sent in the dump. A message could be canned, just in case, at the commencement of each and every action at the point when the logic can construe what that action is to be exactly.
    I am also not confifent that interrupts and premptions are carefully managed... too often asyncronous events and system requests coincide with a crash. Think McAfee, Norton, etc.
    Just some suggestions, but the product is almost unusable as it stands other than for raising the blood pressure of countless hapless users.
    AdelaidePeter

    As this is a user-to-user forum, none of us is in a position to know what plans might be in the works.
    You might want to file a Feature Request with Adobe. They take these seriously.
    Good luck,
    Hunt

  • RE: exception handling

    Wayne,
    When an exception occurs, Forte aborts the inner
    most compound statement, after executing the code
    of an exception handler if there is one. If the excep-
    tion is not handled, it still exists after the compound
    statement was aborted, so Forte now aborts the
    remaining inner most compound statement. This
    continues until Forte reaches the root compound
    statement of the tread (or "task" if you will). This
    one will also be aborted and that is the end of the
    thread (task). If you look at the debugger, you will
    see "RIP" in front of this thread. Sure, this thread
    was spawned by another thread. It was started
    by a "start task" call from within some compound
    statement in the parent thread, but this compound
    statement was probably long since closed. Forte
    can't pass the exception on to a higher level com-
    pound statement, because there is none. If the
    thread started with a method that had a return event
    and an exception event, and you started the task
    with "Completion = event" then Forte will post one
    of these events after the root compound statement
    was finished (in other words, the thread was stopped).
    From this event you can see, if the thread wasfinished succesfully or not.
    Of course, an event is not the same kind of thing
    as an exception. You can't raise events, or post
    exceptions.
    So, when an exception is not handled, only the thread
    where this exception occured is cancelled (including
    all it's child threads). The rest of the treads stay alive.
    -----Original Message-----
    From: Wayne Walker [SMTP:[email protected]]
    Sent: Wednesday 22 July 1998 13:49
    To: '[email protected]'
    Subject: exception handling
    I have a problem in handling exceptions detected in a task. I start a
    task
    which performs some function. I also have an event handler which
    recognizes the method_exception returned should an exception be
    detected.
    Once detected by the event handler I force the exception up to
    another
    process which displays the exception to the user. However, it appears
    that
    forte is intercepting the exception before my event handler can detect
    it
    and posts an exception message. Can anyone explain how this mechanism
    works and the best approach for handling exceptions myself vice Forte?
    Thanks,
    Wayne
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive
    <URL:http://pinehurst.sageit.com/listarchive/>-
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    My understanding is that if your client doesn't care (or cannot handle) the exception,
    you throw your exception WRARPPED with EJBException. This way, the container can
    roll back the transaction properly.
    If your client cares (or have the ability to recover) the exception, you should
    define your own exception. They should not be derived from RuntimeException or
    RemoteException or EJBException. If you want to make sure that the transactions
    are rolled back, you call setRollbackOnly() before you throw the exception.
    Charles
    soraya abbasi <[email protected]> wrote:
    I have tried to make my custom exception subclass RemoteException but
    that doesn't work.
    Does that mean to say you can't have custom exceptions thrown to a client?

  • Generic Exception handler in java

    We have developed a client java application with our own exception hierarchy derived from java.lang.exception. We raise our own exception in case of error scenarios. But there is one additional thing which we want to do:
    1. When ever any exception is raised in our exception we want to do some generic exception handling (like kicking of some module which collects the log files and send it to the administrator.
    2. We want the above activity to happen also when any runtime exception is raised. We are not catching any runtime exception and we have no handle for this.
    How should we go about this. Can we write a very low-level generic exception handler?
    We do not want to have done at every catch block we have in our code. I mean we want to have some hook at a very generic place.
    Let me know if some body can be help me on this.

    As far as I know, for exceptions that are caught, you must make a call to a generic handler in the catch block, or you may rethrow the exception as a RuntimeException, and let it propagate.
    For RuntimeExceptions and Errors in threads that you create, the easiest way to solve this is to subclass ThreadGroup, override uncaughtException with the appropriate code, and create all your threads in this group. For a thread like main, have the first thing in the thread be the creation of a new thread in the new group, then pass control to that thread. For fixed threads, like the event queue, someone had a suggestion already. Note that uncaughtException is only called just before the thread ends, so an exception that shouldn't end the thread should be handled seperately.

  • JRE7: Exception Handler no longer works

    Hello Folks,
    in a large-scale Swing App (usually started via JWS) we used to define a global event handler by setting the "sun.awt.exception.handler" environment variable. This used to work under JRE6, but it doesn't work under JRE7 anymore. What is the replacement?
    Regards from Germany,
    Thomas Nagel

    http://download.oracle.com/javase/1.5.0/docs/api/java/lang/Thread.UncaughtExceptionHandler.html
    ?

Maybe you are looking for