Exception handling across multiple classes

Is it possible to throw the exception from one class to another class for exception handling.............. can anyone tell me the way........

you don't throw it to a specific class. in the method where the exception might be thrown, you can choose to either catch it there, or just re-throw it so that the method before it can choose to catch it or throw it. you know what a stack trace is? it's a chain of methods that were called to get to a certain point in execution, and if an exception is thrown somewhere, either the method in which it is thrown deals with it, or it passes it back to the preceeding method in the stack
why were you trying to throw it to a class?

Similar Messages

  • CV04N-Searching across multiple classes that have the same characteristics

    In CV04N- is there a way to search across mutliple classes that have the same characteristics?
    For example I created 3 new class types each assinged to a new class, each class having the same characteristics.
    Say if I have a characterisitics called Contract Name.  I need to be able to search for a contract name across all 3 classes.
    The search results in CV04N defaults to class type 017 so it only shows characterisitcs relate to that type, Is there a way to get the characteristics for the new created class types to show?
    I know in CV04N you can only search one class type and class at a time.
    Does anyone know of a way to fulfill these requirements, without creating a customized report?

    Hi Jenny,
    The answer for this question is that:
    1. The class 017 document management in cv 04n is SAP standard class .It's totally different than the new class created by you.
    2. The new class in CL02 you are creating is for a perticular document type. When you assign a characteristic (contract name) to this new class ,it appears in additional data field as contract name.
    3. Now you can make a search with only Contract name filed and the report will be displayed with all document types having this characteristic (Contract name) is assigned. Thus you can find the classes(document types)thru characteristic(contract name).
    I hope this will resolve the query. And you will get clarified between two classes( i.e. 017 and new classes in DMS).You can say them as subclassed under 017 class.
    Regards,
    Ravindra

  • Event handling across unrelated classes

    I have a widget type of package that holds some classes that are basically JPanels with appropriate components on them. Specifically, JCheckBox, JComboBox, that kind of thing. These JPanels are used by multiple applications that describe some graphics, so one JPanel allows a user to set properties on Lines, one JPanel allows a user to set properties on Areas, that kind of thing. Several of these are put together in a JTabbedPane, which is another class in this package (this thing can be customized for what is needed).
    The applications themselves use what they need for their particular thing. Here's the question. I designed this thinking that I can have these pre-created panels of what I need, and add the listeners in the application. For example, something like this:
    tabbedPanePanel.getLinePanel().getColorCombo().addItemListener(new ItemListener......);
    When I do this as described in the application, when the colorCombo box is changed, it doesn't trip the event (I was in debug tracing through). Obviously my design is flawed, but I don't know how to change it to make it work. There are two things I need help with improvement.
    First, how can I use these re-usable widgets, when the actions are different depending on the application, and the items that the actions would affect are specific to the applications?
    Second, what would a better design paradigm be for better encapsulation, and performance for these actions (item listeners and such) and the widgets themselves?
    Thank you,
    Valeri

    Think in terms of gathering data instead of actions. That is, each panel gets some user input. Put all the user input in some sort of data object, and provide a method that returns the data object. E.g. Imagine a color panel that lets the user enter R, G, and B:
    public class ColorPanel extends JPanel {
             // TextFields....
            public Color getColor() {
                     // returns a color based on the values in the text fields
    }It is important not to put any OK or Cancel buttons in the panels. You save the OK and Cancel buttons for another main panel that is application specific. When the OK button is pressed, you collect the data and apply it.

  • Transaction Handling across Procedures

    In the ODI Best Practice Guide for Data Warehouses I came across the following (page 100):
    "ODI procedures include an advanced mechanism for transaction handling across multiple steps or even multiple procedures."
    It states that transaction handling can occur across multiple procedures. I could not get this to work.
    I created a procedure with just one step that inserts into a table. In the step I have set the Transaction dropdown to Transaction 0 and the Commit dropdown to No Commit. However, when I execute the procedure the insert is committed as we terminate the session.
    Any ideas how this commit can be prevented?

    ok, I figured out that parameters to the JDBC driver can be specified at the properties tab of the data server.
    So I presume this will be autocommit = false or sth. similar
    I still have to try this out.

  • What is the best way of Exception Handling

    There are many ways to handle the exceptions of a program.
    1: You could put every exception handler in the most upper abstract classes.
    2: You could write a generic exception that handles a lot of things.
    3: You could write exceptions handling for every class.
    4: you could group the exception handling.
    many, many more ways.
    Question:
    What is the best way to do this?

    There are many ways to handle the exceptions of a program.
    1: You could put every exception handler in the most upper abstract classes.I woldn't do that always, a class may throw an exception if it's not able to handle it prperly, but it may, so it'll catch it. Throw Exception in abract supper clases only when you are sure the children must always throw the exception, not processing it.
    2: You could write a generic exception that handles a lot of things.Bad idea, if you always throw an Exception no informtaion is provaided about whta happened, if you throw a NullPointerException and a NumberFormatException in one of your method I (for example) colud handle properly both problems, one likely to be a programming erros, so check my cod eagain, and the other like to be an user error in introduciong some data, so I wold ask him for the data again.
    3: You could write exceptions handling for every class.Write exceptions handling for every class that needs it, throwing the exception if at that moment you don't know what to do with it and catching it if yes. Do not employ too many exception handling: execution of try catch blcks is slower than usuall code.
    4: you could group the exception handling.I don't undestand this. What do youmean?
    Question:
    What is the best way to do this? In general thrwo an exception if the class dosen't know what to do with it, the class which uses yours will handle it. If your class can process the Exception, don't be too lazy and process it.
    Employ exceptions always you need them but do not abuse; thay made the code execute slower because the VM machine must check if the exceotions occur.
    abraham.

  • Pls help..Constructor,setter, getter and Exception Handling Problem

    halo, im new in java who learning basic thing and java.awt basic...i face some problem about constructor, setter, and getter.
    1. I created a constructor, setter and getter in a file, and create another test file which would like to get the value from the constructor file.
    The problem is: when i compile the test file, it come out error msg:cannot find symbol.As i know that is because i miss declare something but i dont know what i miss.I post my code here and help me to solve this problem...thanks
    my constructor file...i dont know whether is correct, pls tell me if i miss something...
    public class Employee{
         private int empNum;
         private String empName;
         private double empSalary;
         Employee(){
              empNum=0;
              empName="";
              empSalary=0;
         public int getEmpNum(){
              return empNum;
         public String getName(){
              return empName;
         public double getSalary(){
              return empSalary;
         public void setEmpNum(int e){
              empNum = e;
         public void setName(String n){
              empName = n;
         public void setSalary(double sal){
              empSalary = sal;
    my test file....
    public class TestEmployeeClass{
         public static void main(String args[]){
              Employee e = new Employee();
                   e.setEmpNum(100);
                   e.setName("abc");
                   e.setSalary(1000.00);
                   System.out.println(e.getEmpNum());
                   System.out.println(e.getName());
                   System.out.println(e.getSalary());
    }**the program is work if i combine this 2 files coding inside one file(something like the last part of my coding of problem 2)...but i would like to separate them....*
    2. Another problem is i am writing one simple program which is using java.awt interface....i would like to add a validation for user input (something like show error msg when user input character and negative number) inside public void actionPerformed(ActionEvent e) ...but i dont have any idea to solve this problem.here is my code and pls help me for some suggestion or coding about exception. thank a lots...
    import java.awt.*;
    import java.awt.event.*;
    public class SnailTravel extends Frame implements ActionListener, WindowListener{
       private Frame frame;
       private Label lblDistance, lblSpeed, lblSpeed2, lblTime, lblTime2, lblComment, lblComment2 ;
       private TextField tfDistance;
       private Button btnCalculate, btnClear;
       public void viewInterface(){
          frame = new Frame("Snail Travel");
          lblDistance = new Label("Distance");
          lblSpeed = new Label("Speed");
          lblSpeed2 = new Label("0.0099km/h");
          lblTime = new Label("Time");
          lblTime2 = new Label("");
          lblComment = new Label("Comment");
          lblComment2 = new Label("");
          tfDistance = new TextField(20);
          btnCalculate = new Button("Calculate");
          btnClear = new Button("Clear");
          frame.setLayout(new GridLayout(5,2));
          frame.add(lblDistance);
          frame.add(tfDistance);
          frame.add(lblSpeed);
          frame.add(lblSpeed2);
          frame.add(lblTime);
          frame.add(lblTime2);
          frame.add(lblComment);
          frame.add(lblComment2);
          frame.add(btnCalculate);
          frame.add(btnClear);
          btnCalculate.addActionListener(this);
          btnClear.addActionListener(this);
          frame.addWindowListener(this);
          frame.setSize(100,100);
          frame.setVisible(true);
          frame.pack();     
        public static void main(String [] args) {
            SnailTravel st = new SnailTravel();
            st.viewInterface();
        public void actionPerformed(ActionEvent e) {
           if (e.getSource() == btnCalculate){
              SnailData sd = new SnailData();
           double distance = Double.parseDouble(tfDistance.getText());
           sd.setDistance(distance);
                  sd.setSpeed(0.0099);
              sd.setTime(distance/sd.getSpeed());
              String answer = Double.toString(sd.getTime());
              lblTime2.setText(answer);
              lblComment2.setText("But No Exception!!!");
           else
           if(e.getSource() == btnClear){
              tfDistance.setText("");
              lblTime2.setText("");
       public void windowClosing(WindowEvent e){
                   System.exit(1);
        public void windowClosed (WindowEvent e) { };
        public void windowDeiconified (WindowEvent e) { };
        public void windowIconified (WindowEvent e) { };
        public void windowActivated (WindowEvent e) { };
        public void windowDeactivated (WindowEvent e) { };
        public void windowOpened(WindowEvent e) { };
    class SnailData{
       private double distance;
       private double speed;
       private double time;
       public SnailData(){
          distance = 0;
          speed = 0;
          time = 0;
       public double getDistance(){
          return distance;
       public double getSpeed(){
          return speed;
       public double getTime(){
          return time;
       public void setDistance(double d){
          distance = d;
       public void setSpeed(double s){
          speed = s;
       public void setTime(double t){
          time = t;
    }Pls and thanks again for helps....

    What i actually want to do is SnailTravel, but i facing some problems, which is the
    - Constructor,setter, getter, and
    - Exception Handling.
    So i create another simple contructor files which name Employee and TestEmployeeClass, to try find out the problem but i failed, it come out error msg "cannot find symbol".
    What i want to say that is if i cut below code (SnailTravel) to its own file(SnailData), SnailTravel come out error msg "cannot find symbol".So i force to put them in a same file(SnailTravel) to run properly.
    I need help to separate them. (I think i miss some syntax but i dont know what)
    And can somebody help me about Exception handling too pls.
    class SnailData{
       private double distance;
       private double speed;
       private double time;
       public SnailData(){
          distance = 0;
          speed = 0;
          time = 0;
       public double getDistance(){
          return distance;
       public double getSpeed(){
          return speed;
       public double getTime(){
          return time;
       public void setDistance(double d){
          distance = d;
       public void setSpeed(double s){
          speed = s;
       public void setTime(double t){
          time = t;

  • Exception Handling for many bean objects of a container class in a JSP page

    Hello,
    I have on container bean class. In this container class, there are several others class objects and the getter methods to get these objects out to the JSP pages.
    I have one JSP page which will use different objects in the container class object through the getter methods of the container class.
    My question is how to implement the exception handler for all the objects in the container so that the JSP page can handle all exceptions if occurrs in any object in the container?
    Please give me some suggestions. Thanks
    Tu

    Thanks for your reply.
    Since the container is the accessor class, I have no other super class for this container class, I think I will try the try catch block in the getter methods.

  • Class based exception handling

    Hi everyone....
    I am new to object oriented abap.
    I would like to know more about exception handling using classes.
    please provide some good material or links on the topic?
    Points will be rewarded.......

    hi,
    Download the PDF from here.
    http://www.esnips.com/doc/6d16a298-9227-4d32-acf1-e91164c89daf/3-ABAP-Objects(P283)
    Follow this link too for tutorials.
    http://www.****************/Tutorials/OOPS/MainPage.htm
    Hope this helps, Do reward.
    Edited by: Runal Singh on Mar 14, 2008 3:28 PM

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

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

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

  • Exception handling class

    hi i have to going to handle error page so for that i want to create
    one helper class which is identify all the exception so this utility class i have to use in my application for handling error page so please if anybody know about how to make this helper class please help me thanks

    First off, you can extend Exception:
    public class MyException extends Exception {
    }You can put some custom messages into the class:
    public class MyException extends Exception {
      public static final String DUPLICATE_RECORD = "Duplicate record in db",
                           WRONG_DATA_TYPE = "Wrong data type",
                           VALIDATION_ERROR = "Invalid data type";
    }Then, have your constructors, which take a String as an argument, so they can get your 'presets' or a custom message:
    public class MyException extends Exception {
      public static final String DUPLICATE_RECORD = "Duplicate record in db",
                           WRONG_DATA_TYPE = "Wrong data type",
                           VALIDATION_ERROR = "Invalid data type";
      public MyException(String message) {
        super(message);
    }You could also have a series of exception classes: DuplicateRecordException, WrongDataTypeException, ValidationException, etc. Hope that helps.
    m

  • Customised Exception handling class.....

    Hello Friends,
    I am working on a project for which I need to create my own exception handling class.
    The reason I need this class is to catch any exceptions and get a customised error message
    according to each exception and then be able to display those messages on web page.
    some examples of the exception I want to catch and display appropriate message are..
    1. a duplicate reord in db
    2. wrong data type (this will deal with ints,doubles and strings data types)
    3. date type validation ( to make sure its date object instead of a string)
    and there are several more messages but if can get some help or idea from any one to design a class for the above errors I might be able to manage other errors as well.
    greatly appreciate any respnses.

    First off, you can extend Exception:
    public class MyException extends Exception {
    }You can put some custom messages into the class:
    public class MyException extends Exception {
      public static final String DUPLICATE_RECORD = "Duplicate record in db",
                           WRONG_DATA_TYPE = "Wrong data type",
                           VALIDATION_ERROR = "Invalid data type";
    }Then, have your constructors, which take a String as an argument, so they can get your 'presets' or a custom message:
    public class MyException extends Exception {
      public static final String DUPLICATE_RECORD = "Duplicate record in db",
                           WRONG_DATA_TYPE = "Wrong data type",
                           VALIDATION_ERROR = "Invalid data type";
      public MyException(String message) {
        super(message);
    }You could also have a series of exception classes: DuplicateRecordException, WrongDataTypeException, ValidationException, etc. Hope that helps.
    m

  • Exception handling in  Data feeder class

    Hi All,
    I have written some code in the DATA class feeder.  there i am catching some exception and i am displaying the exception using the message manager.
    So after catching the exception , its going for dump because , the mo_message , the attribute of the data class has NULL values ,
    But i can able to display the exceptions in form and list feeder classes . because i have referred the data class in both form and list attributes .
    So its getting the instance , but i need to display the exceptions in the data class, how to get the instance of the message interface.
    Please share !
    Thanks,
    Pradeep.

    Hi,
    throw a new JBOException
    Frank

  • Syncing model sources across multiple WARs

    One of the problems we're hitting in our development is keeping model classes synced across a multi-WAR project. For example, the model class for, say, a User object was changed in WAR B, but that developer (an intern) did not publish those changes to WARs A and C. The end result was that a few of our web service calls started failing on the unchanged WARs, while others worked fine.
    I started looking into EJB3, intrigued by the @Remote and @Local setup, but those are related to the session beans themselves. I was hoping that object models could be referenced by interface across multiple WAR distributions as well, though I haven't dug up anything specific on this yet.
    Is there any advice on this forum for keeping model classes in sync across a multiple-WAR project (aside from tighter repository control and swift kicks to the butt)?

    Wraithe wrote:
    Quoting myself: +"The end result was that a few of our web service calls started failing on the unchanged WARs"+
    My original question pertaining to ensuring that the source code for the end user model classes remained consistent. You can't if the interface contains Java classes that are changed. You immediately have to deploy updated JAR files with the new code to all the clients that need it.
    The JAR idea is applicable, though not ideal, and I was hoping there was some other suggestion as to how to handle client-side objects.There is: XML messaging in the service interface instead of Java classes.
    %

  • Fundamental exception handling irritation

    Hello experts,
    I have come across a very disturbing effect when using a function module capable of asynchronous execution in a <i>try-cleanup-endtry</i> statement. Please have a look at the following simple construct:
    TRY.
        do_some_db_update( ).
        start_proc_chain_with_fm( ).
        COMMIT WORK.
      CLEANUP.
        ROLLBACK WORK.
    ENDTRY.
    The method <i>do_some_db_update( )</i> can raise an exception (when the update statement contained in it somehow fails). The method <i>start_proc_chain_with_fm( )</i> uses the fm <i>RSPC_API_CHAIN_START</i> to start some process chain, if it returns with return code <i>failed</i> we raise an exception too.
    That is, both methods potentially raise exceptions. Obviously we only want to commit the involved DB changes if neither does and we want to roll back things if one of the two raises an exception (before propagating the exception to a caller).
    Now, what happens occasionally is that the latter method fails, i.e. it actually raises an exception, however the programm flow executes both, the remaining code in the try-block (i.e. the COMMIT statement) <b>as well as</b> the CLEANUP-branch (i.e. the ROLLBACK statement, which of course has nothing to roll back by then anymore).
    Can somebody please shed some light on this, I am very confused. This behavior upsets the very basis of my understanding of how exception handling in try-catch blocks works.
    Of course I somehow suspect the function module's "asychronous" capabilities.. but actually I think this must not have an effect on the construction as such.
    Regards,
    Sebastian

    Hi Matt,
    thanks for you answer. The exception thrown is indeed my <i>chain_start_failed_ex</i> (my class-based wrapper around/equivalent of the original <i>failed</i>-"exception" returned by the function module). That is, an exception is thrown and the programm flow should definitly continue after the CLEANUP statement. However, this is not always the case.
    As for your proposal this could be a work-around for the concret problem. Nevertheless I would very much like to find a general explanation for this "mystery". In principle I think - regardless of what the methods actually do - the effect discribed should never happen..
    Regards,
    Sebastian

  • How to identify a user across multiple pages

    Hi,
    I'm doing a homebanking and I would like to know how to identify a user across multiple pages.
    I have already take a look at HTTPSESSION, but I didn't understand.
    Can someone help me.
    I'm send the servlet Logon.
    import java.io.*;
    import java.sql.*;
    import java.util.Date;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Cons_logon extends HttpServlet
         private Connection conexao = null;
         Login1 login1;
         public void init (ServletConfig cfg) throws ServletException
              super.init(cfg);
              try
                   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                   conexao = DriverManager.getConnection("jdbc:odbc:bank");
              catch (Exception e)
                   System.out.println(e.getMessage());
         public void doPost (HttpServletRequest req,
    HttpServletResponse res)
    throws ServletException, IOException
              String Suser, Spassword;
         PrintWriter out;
              res.setContentType("text/html");
    out = res.getWriter();
    String opcao = req.getParameter("log");
    Thanks

    I would recommend using the authentication mechanism that's guaranteed by the servlet spec. If you do that, you can just call
    request.getRemoteUser()
    to get the user name across multiple pages.
    If you want to use your own login scheme, you can create a new session object and map it to a user name somewhere in your app. Or you can just put the name of the user on the session. But the preferred way is to use the default authentication scheme defined by the spec.

Maybe you are looking for

  • Installing Photoshop CS3 on a new computer.

    I am about to buy a new PC (old one too slow for Photoshop CS3). As I have already installed CS3 on my old computer, will I have any problem installing it from the same CD on to my new machine? (As CS3 cost more than the computer, I obviously don't w

  • Appending into File using File Adapter

    Hi, I am trying to write to a file, whenever any data is getting inserted into Database table. My scenario is like this: I have created a database adapter which is polling for every new record inserted/updated. After this, I am trying to write the co

  • FTP CONNECTION PARAMETER, SERVER & PORT

    HI m new to xi, i m working with file to file scenario. while creating the sender communication channel for file adapter for the FTP connection parameters, what to give for the server. i dont know my server ip address. m having my own system. i insta

  • Problem downloading Photoshop Elements 12

    I was told my a chat rep to uninstall Elements 12 because it was not working correctly and to reinstall.  I have been trying to do this and I run into a dead end.  I can explain more if someone answers.

  • Skype Crashing When Trying to Receive or Share Scr...

    My skype has been crashing often and almost everytime I try to share screens or my friends try to share screens with me. Below is what I found in Windows Event Viewer, and the File included is my DirectX Diagnostics result.  Faulting application name