SwingWorker and Exceptions in doInBackground() function

Hi. I have GUI and task which communicate with database. I have special class with prepared statements fields, data (returned from database) fields, get methods and construcor. Constructor assume one parameter, query data and fill data fields. So in constructor I perform (maybe) long running task. So I made this subclass SwingWorker in which I create instance of my database class. User type some input (serial number to which he wants to show info), confirm, there start the worker thread. However when he type bad input constructor of database class throws InvalidSnException and then I must show him JOptionPane with error message (or database error occurs). But I shouldn't do that from doInBacground() method because it isn't EventDispatcher thread.
public DbOperations doInBackground()
  DbOperations db = null;
  try {
    db = new DbOperations(sn);
  catch(InvalidSnException) {
  catch(SQLException e) {
  catch(Exception e) {
  return db;
}I don't want to create some additional variables to hold error data, because exceptions hold worth information itself (for example SQLException). Do you know any idea how can solve this?

So you mean that when I invoke JOptionPane method in chatch block in SwingUtilities.invokeLater() function, the code that shows JOptionPane will run on EDT?
When I catch InvalidSnException I just want to show error message and continue some loop to let user type input again, but when I catch SQLException I want show error message and exit with System.exit(-1). Should I use invokeAndWait() instead of invokeLater() ?
Thx

Similar Messages

  • Function Builder - Parameters and Exceptions documentation

    Hallo !
    I am trying to add documentation
    to Z FUNCTION MODULE I have wrote. (in SE37)
    I Can not Find how to add documentation to the parameters and exceptions of the function.
    Sap Library is not very helpful in this topic I think -
    The explanations there are not compatible with
    The interface Gui in SE37 or maybe I did not understand
    something.
    I appreciate your help.
    Thanks,
      N.S.

    hi,
    try these links.
    http://www.intelligententerprise.com/channels/applications/feature/archive/kessler.jhtml
    regs,
    jaga

  • My 3rd iphone. 3GS I did not buy from an apple store, how do I register this serial number with my apple account? it is already sync to it and will preform every function except email to my home computer. It says apple ID disabled

    My 3rd iphone is a 3GS. I did not buy this one from the apple store, how do I register this serial number with my apple account? it is already sync'd and it and will preform every function except email to my home computer. It says apple ID disabled, also will not update my apps, same promt apple id disabled.
    anyone know where I can go to register this phone? Thanks

    https://register.apple.com

  • Customer 9000AAAE : Exception 7 in function module VIEW_KUAG2

    Hi,
    Hi all,
    When I do the intercompany billing for STO (vf01), I got the system message attached below. The customer 9000AAAE is a ship to party and assigned to the ordering plant. It has the partner function SH. So can anybody kindly tell me where is wrong in the custmer master data or somewhere else according to the following message? Or where to find the VIEW_KUAG2? What does it mean?
    Customer 9000AAAE: Exception 7 in function module VIEW_KUAG2
    Diagnosis
    During the attempt to read customer master record 9000AAAE,
    an error occured which is not handled separately.
    System Response
    The billing document for this business transaction was not
    created.
    Procedure
    If the error occured during a background job, you should try
    to create the billing document online. If the error occured
    online, the billing document can be created online. In any
    case, you should check the customer master record. If you
    cannot find any error in the master data, contact SAP.
    Technical data
    Tech. data details
    Client                                                002
    Group Number
    Sales Document Number                  0080100090
    Item Number of the SD Document      000000
    Schedule Line Number                      0083
    Counter in Control Tables                  00
    Message Identification                      VF
    System Message Number                 083
    Output Type                                     E
    Message Variable 01                        9900AAAE
    Message Variable 02
    Message Variable 03                        VIEW_KUAG2
    Message Variable 04
    Group Type                                      F
    In our Intercompany, our ship to party is different from the Sold to, bill to and Payer.  The configuration done as follows -
    a.  Defined Ship to Party as 9000AAAE
    b.  Define Sold to, Bill to, Payer as 9000AAAA
    c.  Assignd Ship to Sold to
    d.  Assigned Ship to customer to plant assignment in STO configuration in MM
    e.  Assigned internal customer of sales organization as 9000AAAA
    Please help in this
    Best Regards
    Goutham

    Hi,
    Thanks for ur reply
    I check the partner determination and the settings are as below -
    a.  Defined new account group for Sold to, Bill to and Payer
    b.  Defined new account group for Ship to
    c.  In the Ship to party account group, system only determine the ship to partner function
    d.  Customer defined in Sold to is assined as interneal customer to sales org
    e.  Customer defined in Ship to is assigned as customer for plant in Shipping data configure for STO in MM Configuration
    Please provide more insights
    Best Regards
    Goutham

  • Regardin handling exception in a function, while using that function in sql

    Hi gurus,
    I have a question regarding logging exceptions while using functions.
    I wrote a separate package to handle errors, where i have a procedure.
    In this proc i'm logging my error into a table and then raise the error to the front end.
    Ex:
    proc_log_and_raise    -- this proc... inserts my error into a table and then raisenow i included this error procedure in all functions and procedures.
    consider an example with a sample procedure and function.
    function func_1(( v_var   varchar2) return varchar2 is
    begin
         select   column2
         from     table2
        where col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;  
    procedure proc_1( v_var   varchar2) is
    begin
        select   func_1(v_var)  -- error occurs here..
        from     table_a
        where   col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;    now i do
    exec  proc_1( v_var );but now my problem is, when an error occurs in func_1, i'm getting an error with DML operation ( as we are inserting into error table)
    ORA-14551: cannot perform a DML operation inside a query.
    so what i want to do is, log both function and procedure where error occured.
    So is there any other better way, we can write our exception handling, so that i can log error and use function in a select statement.
    thank you.

    I changed my procedure a little, to make it simple.
    FUNCTION        PKG_WEEKLY.FUNC_1
                RETURN NUMBER IS 
                exc exception;
    BEGIN                         
                raise exc;
                RETURN           v_provr_rcoupt;
    EXCEPTION
                when exc then
                            PKG.PKG_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'func_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()); 
    END FUNC_1;     
    PROCEDURE    PKG_WEEKLY.PROC_1(
                cur_details                                OUT      sys_refcursor) IS
    BEGIN
                OPEN cur_details FOR
                SELECT            NVL(PKG.PKG_WEEKLY.FUNC_1,0))    FROM DUAL;
    EXCEPTION
                WHEN OTHERS THEN
                            REPORT_APP_PKG.PKG_REPORT_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'PROC_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE());  
    END PROC_1; Now i execute it.
    exec PKG_WEEKLY.PROC_1(:cursor); Error logged into the table:
    242 batch_1 func_1 ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "REPORT_APP_PKG.PKG_REPORT_WEEKLY_CAO", line 230
    04/14/2009 16:09:25
    ERRORS displayed to the front end:
    ORA-20156: ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PKG.PKG_WEEKLY", line 230
    ORA-06512: at "PKG.PKG_ERROR", line 48
    ORA-06512: at "PKG.PKG_ERROR", line 226
    ORA-06512: at "PKG.PKG_WEEKLY", line 261
    thank you

  • Exception Raising in Function Module

    Hi,
    I am having a custom function module that calls a standard function module. Custom function module has following exception defined: manufacture unknown.
    Standard function module has enhancement sections that I implement. For a defined condition I have to raise an exception and return from the function module. However, the exception is not defined in function module.
    Standard exception OTHERS is available. Is it possible to raise OTHERS exception from the code? I have tried statement Raise OTHERS. But it has syntax errors.
    Regards,
    Bhavish Bhatia

    Hi,
    If you raise an exception not defined at exception's tab, sy-subrc will be returned with the number of exception OTHERS.
    Just with the sentece:
    RAISE ZEXCEPTION. (Assuming that ZEXCEPTION is not included at exception's tab).
    Regards,
    Pablo.

  • Client/server RMI app using Command pattern: return values and exceptions

    I'm developing a client/server java app via RMI. Actually I'm using the cajo framework overtop RMI (any cajo devs/users here?). Anyways, there is a lot of functionality the server needs to expose, all of which is split and encapsulated in manager-type classes that the server has access to. I get the feeling though that bad things will happen to me in my sleep if I just expose instances of the managers, and I really don't like the idea of writing 24682763845 methods that the server needs to individually expose, so instead I'm using the Command pattern (writing 24682763845 individual MyCommand classes is only slightly better). I haven't used the command pattern since school, so maybe I'm missing something, but I'm finding it to be messy. Here's the setup: I've got a public abstract Command which holds information about which user is attempting to execute the command, and when, and lots of public MyCommands extending Command, each with a mandatory execute() method which does the actual dirty work of talking to the model-functionality managers. The server has a command invoker executeCommand(Command cmd) which checks the authenticity of the user prior to executing the command.
    What I'm interested in is return values and exceptions. I'm not sure if these things really fit in with a true command pattern in general, but it sure would be nice to have return values and exceptions, even if only for the sake of error detection.
    First, return values. I'd like each Command to return a result, even if it's just boolean true if nothing went wrong, so in my Command class I have a private Object result with a protected setter, public getter. The idea is, in the execute() method, after doing what needs to be done, setResult(someResult) is called. The invoker on the server, after running acommand.execute() eventually returns acommand.getResult(), which of course is casted by the client into whatever it should be. I don't see a way to do this using generics though, because I don't see a way to have the invoker's return value as anything other than Object. Suggestions? All this means is, if the client were sending a GetUserCommand cmd I'd have to cast like User user = (User)server.executeCommand(cmd), or sending an AssignWidgetToGroup cmd I'd have to cast like Boolean result = (Boolean)server.executeCommand(cmd). I guess that's not too bad, but can this be done better?
    Second, exceptions. I can have the Command's execute() method throw Exception, and the server's invoker method can in turn throw that Exception. Problem is, with a try/catch on the client side, using RMI (or is this just a product of cajo?) ensures that any exception thrown by a remote method will come back as a java.lang.reflect.InvocationTargetException. So for example, if in MyCommand.execute() I throw new MySpecialException, the server's command invoker method will in turn throw the same exception, however the try/catch on the client side will catch InvocationTargetException e. If I do e.getCause().printStackTrace(), THERE be my precious MySpecialException. But how do I catch it? Can it be caught? Nested try/catch won't work, because I can't re-throw the cause of the original exception. For now, instead of throwing exceptions the server is simply returning null if things don't go as planned, meaning on the client side I would do something like if ((result = server.executeCommand(cmd)) == null) { /* deal with it */ } else { /* process result, continue normally */ }.
    So using the command pattern, although doing neat things for me like centralizing access to the server via one command-invoking method which avoids exposing a billion others, and making it easy to log who's running what and when, causes me null-checks, casting, and no obvious way of error-catching. I'd be grateful if anyone can share their thoughts/experiences on what I'm trying to do. I'll post some of my code tomorrow to give things more tangible perspective.

    First of all, thanks for taking the time to read, I know it's long.
    Secondly, pardon me, but I don't see how you've understood that I wasn't going to or didn't want to use exceptions, considering half my post is regarding how I can use exceptions in my situation. My love for exception handling transcends time and space, I assure you, that's why I made this thread.
    Also, you've essentially told me "use exceptions", "use exceptions", and "you can't really use exceptions". Having a nested try/catch anytime I want to catch the real exception does indeed sound terribly weak. Just so I'm on the same page though, how can I catch an exception, and throw the cause?
    try {
    catch (Exception e) {
         Throwable t = e.getCause();
         // now what?
    }Actually, nested try/catches everywhere is not happening, which means I'm probably going to ditch cajo unless there's some way to really throw the proper exception. I must say however that cajo has done everything I've needed up until now.
    Anyways, what I'd like to know is...what's really The Right Way (tm) of putting together this kind of client/server app? I've been thinking that perhaps RMI is not the way to go, and I'm wondering if I should be looking into more of a cross-language RPC solution. I definitely do want to neatly decouple the client from server, and the command pattern did seem to do that, but maybe it's not the best solution.
    Thanks again for your response, ejp, and as always any comments and/or suggestions would be greatly appreciated.

  • Runtimr error OBJECTS_OBJREF_NOT_ASSIGNED and Exception  CX_SY_REF_IS_INITI

    Hi All
    when I schedule any BDC pgm in Background by giving job name in SM36 .
    It is giving an runtimr error OBJECTS_OBJREF_NOT_ASSIGNED and Exception  CX_SY_REF_IS_INITIAL .
    Error analysis
        An exception occurred that is explained in detail below.
        The exception, which is assigned to class 'CX_SY_REF_IS_INITIAL', was not
         caught in
        procedure "C14T_LISTTOOL_CALL_ALV_GRID" "(FUNCTION)", nor was it propagated by
         a RAISING clause.
        Since the caller of the procedure could not have anticipated that the
        exception would occur, the current program is terminated.
        The reason for the exception is:
        You attempted to use a 'NULL' object reference (points to 'nothing')
        access a component (variable: "GRID1").
        An object reference must point to an object (an instance of a class)
        before it can be used to access components.
        Either the reference was never set or it was set to 'NULL' using the
        CLEAR statement.
    But it is working fine when i running with options 'N' & 'A' in call transaction. when i execute  I'm searching for sap note but not able to find it,
    If any one can solve this issue please ... its very urgent requirement
    Thanks in Advance

    I believe the better forum to post yorr query to, will be [ABAP, General|ABAP Development;.
    From the header of that forum:
    General questions about the ABAP language and language implementations.
    This is not a forum for application specific questions. Web Dynpro , BSP , CRM
    development, ... have their own forums.
    - Ludek

  • TREX Error : Exception condition "UNKNOWN FUNCTION" raised.

    Hi All,
    When i try to search for a product in the SAP CCM catalog, i am getting a dump "Exception condition "UNKNOWN FUNCTION" raised. ".
    If anyone has faced similar error before, please help me resolve it.
    Thanks
    NishKel

    Hi
    Which TREX / CCM Version are you using ?
    What is the detailed Dump message ? Please paste the details using ST22 Transaction.
    <b>Other related SAP OSS Notes to check out -></b>
    Note 969660 6.20/6.40 Patch Collection Installation : Unix
    Note 1019227 DBM Package archivation
    Note 1017750 DBM Order Archiving
    Note 846657 TREX 6.1 XML attribute extractor doesn't work
    Note 1006014 Lock of SINGLE_TABLE_INDEX 
    Note 932771 BIA: Change run, locks and initial indexing
    Note 712341 ISA-R/3: No configuration possible when TREX is used
    Note 733873 Publication of individual catalog items
    Note 572940 Reduction of the number of index tables for area attributes
    Do let me know.
    Regards
    - Atul

  • Customer : Exception 7 in function module VIEW_KUxxV

    Hi,
    While Billing facing this problem
    00 Customer : Exception 7 in function module VIEW_KUxxV
    10 The bill-to party could not be determined
    10 The payer could not be determined
    tx in advance
    Bhushan Kolte

    Hello Colleague;
    Please check the account group assignment to the partner functions in   
    transaction VOPA click on partner function button then environment      
    then Account group assignment. Please ensure that this is all configured
    correctly for the partners.                                                                               
    Please also review the note                                    
    -> 80233   Debit-side settlement: Customizing, error messages                                                                               
    In particular the section:                                              
    VF083: 'Customer &: Exception & in function module VIEW_KUAGV'                                                                               
    The error message is generated because of a program error that          
    has since been corrected. The correct error message is VP304,           
    'Customer belongs to customer group & and thus cannot be the            
    sold-to party'.                                                                               
    The partner roles in the customer master are incorrectly set, see       
    below.                                                                               
    Recommendation: Assign the customer an account group which              
    already fulfills these criteria. (In the standard system, this is       
    Account group '0001).                                                                               
    I hope this helps resolve the error.
    Regards
    Ruy Castro

  • Exception 7 in function module VIEW_KUAG2

    Hi all,
    When I try to process a Billing document in transaction VF04, has an error message "Customer 12334: Exception 7 in function module VIEW_KUAG2".
    Could you advise me why I receive this message?
    Is it possible that Customer master data it is not maintained propertly?

    Hi,
    When I checked there are only 5 exceptions for this functional module.  By the way which version are you in?  If you want to find out what the exception 7 is then go to SE37 and display this functional module.  There you can find a tab for exceptions.  Based on that you can proceed with changes in the customer master. 
    Its definitely the possibility of not maintaining the customer properly.
    Hope this helps.
    Thanks
    Krishna.

  • Captivate 7 question - slide with audio and light boxes not functioning properly

    I am currently working a project and cannot figure something out. 
    I have a slide with 9 smartshape buttons on it.  When each button is clicked it brings up a lightbox.  Each lightbox has it's own close button. When the lightbox is closed by the user then the user immediately sees the 9 button screen and can choose another button to view and read, and so forth.  I have the lightboxes working fine.
    Now, I added text to speech.  It is a mere 15 seconds in length, but it contains some important content and the directions.  I want the text to speech audio to stop playing if the user goes ahead and clicks on one of the 9 buttons which then brings up a lightbox.  I want the audio to then resume when they close the lightbox.  OK I have all of that working in a technical sense.
    I've also tried this advanced action, but this stops the Audio entirely, however it does solve the autoadvance issue. so I am just trading issues.
    I also have  "back and next" nav buttons on the slide, so the user must click one or the other to proceed off the slide.  Ok those worked.
    Here is the issue.  Once I added the text to speech audio, at the end of 17.3 seconds, whatever lightbox the user may be viewing and they hit the close lightbox button, captivate automatically sends the user to the next slide.  No clicking "Next" or anything.  I can't figure out why this is occurring. 
    Prior to adding audio the slide worked as it should with the user being able to click each of the 9 buttons to "read some info" then close it and click another button on the slide, etc.  They could do this in any order they wanted. 
    When I added the audio, I set the advanced actions so if a user clicked on one of the buttons, the audio would stop playing until they came back to the main screen.  Ok no problem getting that to function - except it stops functioning at the end of 17.3 seconds. 
    What am I missing?
    Thanks for any help!!!
    Michelle

    Correct I have only 15 seconds of audio with the slide.  no audio with any of the light boxes.  Those are "read only" light boxes.
    If the user clicks a shape button early, before the entire audio has played, I want the audio to stop, so the user can read the lightbox info, then as they click back to the slide away from the lightbox, I want the audio to resume playing - so they can hear the rest of the audio.  But,  this is where is doesn't function properly as when the audio finishes playing at 15 seconds.  The next shape button the user clicks on to shows the lightbox, but when they click to close the lightbox, the lightbox closes then sends the user to the next slide.  They haven't had a chance to view any of the other shape buttons and the information found in those corresponding light boxes. 
    I hope this clarifies.
    Any thoughts?
    Michelle

  • Define our own Exceptions in th function builder

    hi
    how to define our own Exceptions in th function builder in the Exception tab and how to use them in functon definiton.
    regards
    ravish

    Hi,
    <b>Exceptions</b>
    The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
    The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
    The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
    <b>Note</b>
    For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
    Regards,
    Padmam.<b></b>

  • Why there's error stating "unreported exception" when call function

         public void actionPerformed(ActionEvent evt)
              Object obj = evt.getSource();
              if (obj == DeleteButton)
                   readfile(); // Error here
                   deletefile();
                   rename();
    ========================================================================
         public void readfile() throws Exception
              BufferedReader in = new BufferedReader(new FileReader("WhiteCollar2.txt"));
              line=in.readLine();
              found=0;
              while (line!=null)
                   if ((line.substring(0,6)).equals((String)textfield.getText()))
                        System.out.println("CORRECT\n");
                        found=1;
                   else
                        writefile();                    
                   line=in.readLine();
    ========================================================================
    How come when I call the above readfile(), it gives me :
    DeleteScreen.java:70: unreported exception java.lang.Exception; must be caught or declared to be thrown
    readfile();
    However if I change to the following :
    try{readfile()};
    catch (Exception e) {}
    The code works fine. I am still figuring out on throwing exceptions etc. But how come I already throw exceptions it still complains exception not declared?
    Thanks and Rgds

    but the writefile() function which I called in the
    read() also throw exception but how come I do not need
    to catch it for the write()?The error message says it all: must be caught or declared to be thrown. Thus, you must either catch the exception using try-catch or you must declare that your method throws the exception using the throws declaration.
    Your call to writefile() is in the method readfile() that already declares that it throws Exception. So there is no problem there.
    BTW, you should know that it is generally ill-advised to catch or declare exception using the superclass Exception. You should use as specific an exception class as possible. In this case I suppose it would be IOException.

  • *Fatal Error: Unexpected exception processing text functions*

    Hi All,
    Could anyone provide guidance on the error below? when I tried to run particular report and I get the error below. We are using 11.1.1.3
    "*Fatal Error: Unexpected exception processing text functions*"
    Thanks in Advance.

    Which product are we specifically talking about?
    Please let me know.
    Thank you,
    Todd Rebner

Maybe you are looking for

  • Error after running Projector for a while

    I run a projector in a kiosk. When being used there is no problem, but at night if it is not being used for a bit I get one of two errors Faulting application dirproj.exe, version 10.1.0.11, faulting module iml32.dll, version 10.1.0.11, fault address

  • PLEASE HELP NEED SOME ADVICE

    i joined bt on the 17th may with my fone line tv n broadband and i was quite happy with the service  for the 9 days it was working but after just 9 days my vision went down and i rang up wasnt to happy went i was told i would have to wait till the 8t

  • Chinese font not showing up in Illustrator

    Greetings, I am having a problem getting a font to show up in Illustrator (and every Adobe app) but it appears just fine in Word. The font is located here: http://www.ibiblio.org/chinesehistory/contents/08fea/c02.html and is called "HanDing-CS" (HDZB

  • Posting Key

    Error message is displaying while posting vendor payment transaction through F-53, that message is Posting key not defined. Message no is F5817 Diagnosis is Service Financial accounting: posting keyl "" was not found in the posting key table I checke

  • How to use FM named 'TABLE_COMPRESS'

    i am using FM named 'TABLE_COMPRESS' it is sending compressed values via function module  'SO_NEW_DOCUMENT_ATT_SEND_API1' (in attachment) but i am not able to see content after mail is sent.