vm/src/test/java/org/apidesign/vm4brwsr/Exceptions.java
author tzezula
Sat, 08 Dec 2012 08:19:46 +0100
branchexceptions
changeset 285 c8be2d837788
child 287 6f696a0ef12f
permissions -rw-r--r--
Original version of exception handling.
tzezula@285
     1
/*
tzezula@285
     2
 * To change this template, choose Tools | Templates
tzezula@285
     3
 * and open the template in the editor.
tzezula@285
     4
 */
tzezula@285
     5
package org.apidesign.vm4brwsr;
tzezula@285
     6
tzezula@285
     7
/**
tzezula@285
     8
 *
tzezula@285
     9
 * @author tom
tzezula@285
    10
 */
tzezula@285
    11
public class Exceptions {
tzezula@285
    12
tzezula@285
    13
    public static int methodWithTryCatchNoThrow() {
tzezula@285
    14
        int res = 0;
tzezula@285
    15
        try {
tzezula@285
    16
            res = 1;
tzezula@285
    17
        } catch (IllegalArgumentException e) {
tzezula@285
    18
            res = 2;
tzezula@285
    19
        }
tzezula@285
    20
        //join point
tzezula@285
    21
        return res;
tzezula@285
    22
    }
tzezula@285
    23
tzezula@285
    24
    public static int methodWithTryCatchThrow() {
tzezula@285
    25
        int res = 0;
tzezula@285
    26
        try {
tzezula@285
    27
            res = 1;
tzezula@285
    28
            throw new IllegalArgumentException();
tzezula@285
    29
        } catch (IllegalArgumentException e) {
tzezula@285
    30
            res = 2;
tzezula@285
    31
        }
tzezula@285
    32
        //join point
tzezula@285
    33
        return res;
tzezula@285
    34
    }
tzezula@285
    35
tzezula@285
    36
}