How to catch ALL Exception in ONE TIME

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

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

Similar Messages

  • How to catch all logs to one file with rsyslog?

    Hi,
    I have this config in rsyslog:
    # cat /etc/rsyslog.conf
    # Minimal config
    $ModLoad imuxsock # provides support for local system logging
    $ModLoad imklog # provides kernel logging support
    $ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat
    $FileOwner root
    $FileGroup root
    $FileCreateMode 0640
    $DirCreateMode 0755
    $Umask 0022
    $WorkDirectory /var/spool/rsyslog
    $IncludeConfig /etc/rsyslog.d/*.conf
    # Un sol log
    *.* /var/log/missatges.log
    # Si hi ha notificacions crítiques (pànic), enviar per consola a tots els usuaris
    *.emerg :omusrmsg:*
    [root@serviedre ~]#
    but in 'missatges.log' there is no systemd-timesyncd output:
    # journalctl -n
    -- Logs begin at Fri 2010-01-01 01:00:05 CET, end at Mon 2014-12-08 18:33:08 CET. --
    Dec 08 18:31:20 serviedre systemd[162]: Starting Default.
    Dec 08 18:31:20 serviedre systemd[162]: Reached target Default.
    Dec 08 18:31:20 serviedre systemd[162]: Startup finished in 168ms.
    Dec 08 18:31:20 serviedre systemd[1]: Started User Manager for UID 0.
    Dec 08 18:31:44 serviedre systemd-timesyncd[129]: Using NTP server 86.59.80.170:123 (2.europe.pool.ntp.org).
    Dec 08 18:31:31 serviedre systemd[162]: Time has been changed
    Dec 08 18:31:31 serviedre systemd-timesyncd[129]: interval/delta/delay/jitter/drift 32s/-12.456s/0.115s/0.000s/+0ppm
    Dec 08 18:31:31 serviedre systemd[1]: Time has been changed
    Dec 08 18:32:03 serviedre systemd-timesyncd[129]: interval/delta/delay/jitter/drift 64s/+0.001s/0.113s/0.000s/+0ppm
    Dec 08 18:33:08 serviedre systemd-timesyncd[129]: interval/delta/delay/jitter/drift 128s/+0.004s/0.114s/0.001s/+15ppm
    [root@serviedre ~]# cat /var/log/missatges.log | grep drift
    [root@serviedre ~]#
    Why?
    Last edited by xanb (2014-12-17 09:54:50)

    This happens with a lot of info: `journalctl -b` prints:
    Dec 17 09:36:16 serviedre systemd[6276]: Received SIGRTMIN+24 from PID 6328 (kill).
    Dec 17 09:36:16 serviedre systemd[6277]: pam_unix(systemd-user:session): session closed for user root
    Dec 17 09:36:16 serviedre systemd[1]: Stopped User Manager for UID 0.
    Dec 17 09:36:16 serviedre systemd[1]: Stopping user-0.slice.
    Dec 17 09:36:17 serviedre systemd[1]: Removed slice user-0.slice.
    Dec 17 09:41:38 serviedre systemd-timesyncd[133]: interval/delta/delay/jitter/drift 2048s/-0.000s/0.099s/0.000s/+55ppm
    Dec 17 09:55:51 serviedre sshd[6333]: Accepted password for root from 172.26.0.7 port 35114 ssh2
    Dec 17 09:55:51 serviedre sshd[6333]: pam_unix(sshd:session): session opened for user root by (uid=0)
    Dec 17 09:55:51 serviedre systemd[1]: Starting user-0.slice.
    Dec 17 09:55:51 serviedre systemd[1]: Created slice user-0.slice.
    Dec 17 09:55:51 serviedre systemd[1]: Starting User Manager for UID 0...
    Dec 17 09:55:52 serviedre systemd[1]: Starting Session c2 of user root.
    Dec 17 09:55:52 serviedre systemd-logind[137]: New session c2 of user root.
    Dec 17 09:55:52 serviedre systemd[6335]: pam_unix(systemd-user:session): session opened for user root by (uid=0)
    Dec 17 09:55:52 serviedre systemd[1]: Started Session c2 of user root.
    Dec 17 09:55:52 serviedre systemd[6335]: Starting Paths.
    Dec 17 09:55:52 serviedre systemd[6335]: Reached target Paths.
    Dec 17 09:55:52 serviedre systemd[6335]: Starting Timers.
    Dec 17 09:55:52 serviedre systemd[6335]: Reached target Timers.
    Dec 17 09:55:52 serviedre systemd[6335]: Starting Sockets.
    Dec 17 09:55:52 serviedre systemd[6335]: Reached target Sockets.
    Dec 17 09:55:52 serviedre systemd[6335]: Starting Basic System.
    Dec 17 09:55:52 serviedre systemd[6335]: Reached target Basic System.
    Dec 17 09:55:52 serviedre systemd[6335]: Starting Default.
    Dec 17 09:55:52 serviedre systemd[6335]: Reached target Default.
    Dec 17 09:55:52 serviedre systemd[6335]: Startup finished in 143ms.
    Dec 17 09:55:52 serviedre systemd[1]: Started User Manager for UID 0.
    Dec 17 10:15:46 serviedre systemd-timesyncd[133]: interval/delta/delay/jitter/drift 2048s/-0.000s/0.100s/0.000s/+55ppm
    Dec 17 10:19:43 serviedre systemd[1]: Reloading.
    Dec 17 10:19:44 serviedre systemd[1]: Unknown serialization item 'subscribed=:1.0'
    but
    [root@serviedre ~]# tail /var/log/missatges.log
    Dec 14 18:33:12 localhost kernel: [ 4.959569] mmcblk0: p1
    Dec 14 18:33:12 localhost kernel: [ 6.833607] EXT4-fs (sda1): re-mounted. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 9.783482] EXT4-fs (sda8): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 9.885975] EXT4-fs (sda5): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 10.004117] EXT4-fs (sda6): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 10.109992] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 10.243718] EXT4-fs (sda7): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 10.596835] EXT4-fs (sda3): mounted filesystem with ordered data mode. Opts: discard
    Dec 14 18:33:12 localhost kernel: [ 12.914250] sunxi_emac sunxi_emac.0: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
    Dec 14 18:33:22 localhost kernel: [ 23.247589] eth0: no IPv6 routers present
    [root@serviedre ~]#

  • How do I close all tabs at one time without closing Firefox completely?

    How do I close all tabs at one time without closing Firefox completely?

    Open a new window. Go to the other window with all the tab. Close it. You now only have that newly open window.
    Hub

  • How to delete all data in all tables in one time ?!

    1 CREATE OR REPLACE PROCEDURE delete_all_data
    2 IS
    3 v_statement VARCHAR2 (200);
    4 BEGIN
    5 FOR i IN (SELECT *
    6 FROM user_tables)
    7 LOOP
    8 v_statement :=
    9 'delete table ' || i.table_name ;
    10 EXECUTE IMMEDIATE v_statement;
    11 END LOOP;
    12 commit;
    13* END;
    SQL> /
    Procedure created.
    SQL> exec delete_all_data
    BEGIN delete_all_data; END;
    ERROR at line 1:
    ORA-00903: invalid table name
    ORA-06512: at "DE2.DELETE_ALL_DATA", line 10
    ORA-06512: at line 1
    I made the previous code , but it's didn't work with me .... any help for this problem please ?!
    I'm just reminder ..... all what I need ,that delete all data in all tables in one time only .
    I'm waiting for the answer ..... and thanks in advance

    create or replace
    FUNCTION TRUNC_SCHEMA RETURN NUMBER AS
    CURSOR select_table IS SELECT TABLE_NAME AS TNAME FROM USER_TABLES ORDER BY 1;
    sTableName Varchar2(128);
    sUser Varchar2(128);
    sConstraintName Varchar2(128);
    plsql_block Varchar2(512);
    BEGIN
    SELECT USER INTO sUser FROM DUAL;
    IF ((sUser='SYSTEM') OR (sUser='SYS')) THEN
    RETURN 1;
    END IF;
    EXECUTE IMMEDIATE 'PURGE RECYCLEBIN';
    -- DISABLE table's constraints
    FOR C1 IN (select CONSTRAINT_NAME, TABLE_NAME from user_constraints where STATUS = 'ENABLED' AND CONSTRAINT_TYPE in ('P','R') ORDER BY R_CONSTRAINT_NAME) LOOP
    sConstraintName := C1.CONSTRAINT_NAME;
    sTableName := C1.TABLE_NAME;
    plsql_block := 'ALTER TABLE ' || sTableName || ' DISABLE CONSTRAINT ' || sConstraintName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    FOR D IN select_table LOOP
    --get table name
    sTableName := D.TNAME;
    -- clear table
    plsql_block := 'TRUNCATE TABLE ' || sTableName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    -- ENABLE table's constraints
    FOR C2 IN (select CONSTRAINT_NAME, TABLE_NAME from user_constraints where STATUS = 'DISABLED' AND CONSTRAINT_TYPE in ('P','R') ORDER BY R_CONSTRAINT_NAME desc) LOOP
    sConstraintName := C2.CONSTRAINT_NAME;
    sTableName := C2.TABLE_NAME;
    plsql_block := 'ALTER TABLE ' || sTableName || ' ENABLE CONSTRAINT ' || sConstraintName;
    EXECUTE IMMEDIATE plsql_block ;
    END LOOP;
    RETURN 0;
    EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('ERROR: ' || SQLERRM);
    RETURN 1;
    END TRUNC_SCHEMA;
    /

  • HOW DO YOU" DELETE BOOKMARKS" AT ONE TIME WITHOUT DELETING ALL.

    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    How do you" delete bookmarks" at one time, but not all of them. For instance highlight the ones you don't want. But with Fx that doesn't work. I love Fx and tell everyone I know about you and have for years. Please help !!!!!
    == Troubleshooting information
    ==
    How do you" delete bookmarks" at one time, but not all of them. For instance highlight the ones you don't want. But with Fx that doesn't work. I love Fx and tell everyone I know about you and have for years. Please help !!!!!
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
    == Plugins installed
    ==
    *-Shockwave Flash 10.0 r32
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.2"
    *NPRuntime Script Plug-in Library for Java(TM) Deploy
    *Google Update
    *Java(TM) Platform SE binary
    *Next Generation Java Plug-in 1.6.0_20 for Mozilla browsers
    *Npdsplay dll
    *DRM Store Netscape Plugin
    *DRM Netscape Network Object

    Please take a look at knowledge base article [[Deleting Bookmarks]] on how to delete one or more bookmarks at once.

  • A catch-all "exception handler" - what's the end of an stack trace?

    I've created an application that is beeing tested these days, and I thought it would be a good idea to implement a "catch-all" exception handler so that I could notify the user when an exception occur (so that he may stop, send me the log, and to prevent errors that occur as a result of the first one).
    The way I've started implementing it is I redirect error out to a custom output stream:
    public class ConsoleOutStream extends ByteArrayOutputStream {
        private JFrame owner;
        public ConsoleOutStream(JFrame owner) {
            this.owner = owner;
         * Writes <code>len</code> bytes from the specified byte array
         * starting at offset <code>off</code> to this byte array output stream.
         * @param   b     the data.
         * @param   off   the start offset in the data.
         * @param   len   the number of bytes to write.
        public synchronized void write(byte b[], int off, int len) {
            super.write(b, off, len);
            checkForExceptions();
         * Writes the specified byte to this byte array output stream.
         * @param   b   the byte to be written.
        public synchronized void write(int b) {
            super.write(b);
            checkForExceptions();
        private void checkForExceptions() {
            reset();
            if(this.toString().indexOf("xception") != -1) {
                System.out.println("Exception!!\n\n");
                System.out.println(this.toString());
    }then i redirect System.err:
    PrintStream out = new PrintStream(new ConsoleOutStream(this));
    System.setErr(out);
    The problem is that the checkForExceptions() method will be called, e.g. 3 times for each exception - and I just want to display an error message to the user once (of course).
    Anyone done something similar?

    I'm interested in catching all "unhandled errors"how about:
    public static void main(String[] args){
        try{
        //whatever you would normally call from main
        }catch (Throwable e){
             System.out.println("There was an unhandled exception:");
             e.printStackTrace();
    }

  • How can I clean up queue one-time on Sun Java system messaging 6.3

    Hi,
    <address>Our Email server have a problem, When I run _./imsimta qm directory tcp_local_, There are about 5 Millions of messages in the queue.</address>
    Now our Email server send messages very slowly, how can I clean up queue one-time?
    the command _./imsimta qclean_ is very slowly.
    What can I do to prevent this problem?
    our Email server version is :
    Sun Java(tm) System Messaging Server 6.3-6.03 (built Mar 14 2008; 32bit)
    libimta.so 6.3-6.03 (built 17:12:37, Mar 14 2008; 32bit)
    SunOS email-1 5.10 Generic_120011-14 sun4u sparc SUNW,Sun-Fire-V890
    Thank you !

    If you have more than 100,000 messages in the queue, then look at the MAX_MESSAGES parameter in [the job_controller.cnf file|http://wikis.sun.com/display/CommSuite/Job+Controller+Configuration+File]. If the parameter is not specified, it defaults to 100000. If you have more than that number of messages in the channel queues, it will take a long time for new/legitimate messages to be sent because job_controller is only considering the first 100,000 messages in the queue.
    If you get into the "imsimta qm" command do do "sum -database", it will show a summary of what job_controller has in its internal cache and therefore what job_controller is working on. If you compare that to "sum -directory" you will probably see a difference.
    If these are all legitimate messages, you need to increase MAX_MESSAGES, cnbuild, and restart job_controller.
    If they are not, then preventing this in the future will require determining how they got into your queue and correcting that.
    As for removing them, the "imsimta qm" commands allow you to select messages by various criteria and then you can "return" or "delete" them. But yes, that will take a long time if there are many messages because it is a single threaded process and it needs to open and examine each message. You may be able to accomplish the task more quickly with a shell script that works on individual channel queue subdirectories and then run multiple copies of that script in parallel. After you have cleaned out the queue, restart job_controller.
    Also, you might want to consider [the subdirs channel keyword|http://msg.wikidoc.info/index.php/Subdirs_and_nosubdirs_Channel_Options].

  • How to delete all mails with one klick?

    It's annoying to delete every single mail.
    How to delete all mails with one klick, like in the paperbasket?
    Thanks

    If the emails have been previously deleted (I.e. in the trash folder), tap Edit at the top of the list. You should see a delete all button at the bottom. If the messages are in a standard folder, they need to be handled one at a time.

  • How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and Power Book

    How do I transfer data from one time capsule to new time capsule when TC backs up an iMac and MacBookPro

    It is generally better to leave the old backups and start again.. unless there is something you particularly need.
    But if you desperately want all the old backups you have to copy the sparse bundles.. this will take very long time as it must copy via the computer..
    http://pondini.org/TM/18.html
    Take particular note of the initial comments.. ie before you read how to do it.. don't do it.

  • How to download 'all photos at a time' from shared stream?

    I have a photo stream shared album (with 120 pictures) on icloud.  This is shared from iPhone.  I opened the link on my mac/windows in the browser.  Now, how to download 'all photos at a time' from shared stream?  I don't want to download each photo at a time.  There are 100s of photos to download.  I can't open one photo at a time and keep downloading them separately.  There should be a way to download all photos from a shared stream.  Please let me know how you are dealing with this?

    1.you need create a dba user in your database
    2.you can run the script as command
    eg. use PL/sql developer ->new command window->open script-> run.

  • Best Practice: JavaFX pattern for "Catching all Exceptions"

    Hi,
    what is on the current JavaFX Standard the best way to catch all Exceptions (centralized) within my JavaFX application...
    I read thread outside this Oracle Forum who recommend following:
    1. Thread.setDefaultUncaughtExceptionHandler(new MyExceptionHandler());
    --> catch all runtime exceptions
    2. http://stackoverflow.com/questions/12318861/javafx-2-catching-all-runtime-exceptions
    --> Implementing some source code who wrap the current GUI thread...
    3. I read something like:
    "JavaFX exception handling is almost identical to that in Java, apart from the fact that checked exceptions are handled in the same way as unchecked exceptions. This is good news for most Java programmers moving to JavaFX because you are no longer obliged to catch and handle exceptions."
    Sounds very good! But where/how can I do this ???
    Edited by: wschele on 19.02.2013 04:58
    Edited by: wschele on 19.02.2013 05:16

    No recommendation whats the best way to do it?
    Catching each Exception in different layers is boring ! :-(

  • How create multiple named folders at one time? 10.10.02

    How create multiple named folders at one time? 10.10.02
    Hello all,
    I need to create 208 named folders at one time. Please advise.
    Thanks!

    You may want to ask this in the Yosemite forum. This is the Mavericks forum.

  • Search-Mailbox can't get all the items one time

    Support there are 10 items are satisfied the following search condition,then if I run the following commands, it should delete all the 10 items.
    but to my surprise, when I run the following command ,it just delete part of the 10 items, such as 5, or 8 .
    so I have to run the command once again to delete the remains items
    So my question is how to delete all of the 10 item one time? why I can't delete all of them one time?
    Search-Mailbox -Identity "administrator" -searchdumpsteronly -SearchQuery 'retentionpolicy:"NONARCHIVETAG"' -DeleteContent -confirm:$false -Force
    Please click the Mark as Answer button if a post solves your problem!

    Hi,
    Could you please create a new test mailbox and delete the messages by using subject query? Is it the same issue?
    Best regards,
    Belinda
    Belinda Ma
    TechNet Community Support

  • How to print all columns in one page

    Hi,
    Can anybody explain me how to print all columns in one page.we have around 15 to 20 columns for 4 reports and all these reports are build on one multiprovider.we are using BW 3.5.
    Can anyone explain me  how to print ALL COLUMNS IN ONE PAGE  .currently they are getting all columns in 2 to 3 pages. They are using PORTAL to run the reports here.
    Is it possible to do by customizing Webtemplate or by macros in Workbook.Please help me
    Edited by: kotha123 on Oct 11, 2010 5:58 PM

    Hi,
    Your best bet is to use a workbook template or else Excel to pdf option...Thanks

  • How to divide all textFrames in one-character-per-textFrame?

    Hello:
    How to divide all textFrames in one-character-per-textFrame?
    Example: the textFrame "Letters" will be divided in 7 textFrames: "L", "e", "t", "t", "e", "r", "s".
    Help, please.

    Hi Paul, try this one
    #target Illustrator
    //  script.name = splitSelectedFramesIntoWords2.0.jsx;
    //  script.description = splits selected texFrames into separate words;
    //  script.required = select point text textFrames before running;
    //  script.parent = CarlosCanto;  // 10/14/11
    //  script.elegant = false;
    var idoc = app.activeDocument;
    var sel = idoc.selection; // get selection
    var selCount = sel.length; // count items
    var tFrames = []; // to hold the textFrames
    for (j=selCount ; j>0 ; j--) // loop thru selection & get textFrames backwards
                        tFrames[j-1] = sel[j-1];
    for (k = 0 ; k<tFrames.length ; k++) // loop thru textFrames
                        var xpos = tFrames[k].position[0]; // get x
                        var ypos = tFrames[k].position[1]; // get y
                        var words = tFrames[k].contents.split(/\s/g); // get all words into an array
                        //$.writeln(words);
                        var space = tFrames[k].duplicate(); // dup to get width of a space
                        space.contents = " ";
                        var sw = space.width;
                        space.contents = words[0]; // replace space with first word
                        var w = space.width;
                        var wordCount = words.length; // count words
                        for (i=1; i<wordCount ; i++) // loop thru words
                                            xpos2 = xpos+w+sw; // next words position = previous word pos+width+space
                                            var iword = space.duplicate(); // duplicate previous word
                                            iword.contents = words[i]; // add next word
                                            iword.position = [xpos2,ypos]; // position the character = original position + new width
                                            w = iword.width; // get words width
                                            xpos = iword.position[0]; // get words position
                        tFrames[k].remove(); // remove textFrame

Maybe you are looking for

  • Cast error in JSP page

    if this is not the right forum, please some one show where. I created a EJB pack and deployed at the server. Made a java program client to test it and all is Ok. But when I try to use a jsp page to use the service, I get a java.lang.ClassCastExceptio

  • Is it possible to change the automatically set image on the new iMovie Theater title screen?

    I made a few movies on the new iMovies 2013 then uploaded into iTheater. I love the software and its ease of use. However, I noticed iTheater automatically sets the title image. Similar to youtube, iTheater probably uses the video mid point image as

  • GR needs higher Quantity than STO Purchase order Qunatity

    Dear Friend, Pl suggest whicle in case of STO Purchase order, I want to receive higher quantity than PO qunatity. After doing all Captured part-I, when Check button is activated..it showing PL Stock in transit exceeded by 0.500 MT : FIN500 1000 FSMS

  • Change in Std SAP Program

    BW Experts, At my client I have changed a Std SAP program LRRSVF20. This was transported up all the way to production. Now that we did a Support pack upgrade in dev, This configuration is lost in development. What is the best approach to get it back.

  • Background pic for DVD menu

    I know that you can drop a pic into the menu background for your DVD, but I can't figure out how to strech or resize the pic from there. Most of the time, the pic is too big and I need to shrink it down to the size of the menu background. I know that