summaryrefslogtreecommitdiffstats
path: root/third_party/jmake/src/org/pantsbuild/jmake/PublicExceptions.java
blob: 40097454d0c5cf952cd2485a40f6457535552308 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/* Copyright (c) 2002-2008 Sun Microsystems, Inc. All rights reserved
 *
 * This program is distributed under the terms of
 * the GNU General Public License Version 2. See the LICENSE file
 * at the top of the source tree.
 */
package org.pantsbuild.jmake;

/**
 * This class is a wrapper for a number of nested classes. They define exceptions that may be thrown
 * by the <b>jmake</b> code. These exceptions are caught in the <code>Main.mainExternal</code> method,
 * or they may be caught and handled by an application invoking <b>jmake</b> programmatically
 * through <code>Main.mainProgrammatic</code> method.
 *
 * @see Main#mainExternal(String[])
 * @see Main#mainProgrammatic(String[])
 *
 * @author  Misha Dmitriev
 *  17 January 2003
 */
public class PublicExceptions {

    /**
     * This exception is thrown whenever there is any problem initializing or calling the compiler, or
     * when the compiler itself reports compilation errors. Depending on the nature of the problem, an
     * instance of this class is initialized with, and then returns, an original exception signalling
     * the problem, or the compiler application exit code.
     */
    public static class CompilerInteractionException extends Exception {

        private static final long serialVersionUID = 1L;
        private Exception originalException;
        private int compilerExitCode;

        /**
         * Initialize an instance of this exception with an error message and either an original
         * exception or a compiler exit code.
         */
        CompilerInteractionException(String msg, Exception originalException, int compilerExitCode) {
            super(msg);
            this.originalException = originalException;
            this.compilerExitCode = compilerExitCode;
        }

        /**
         * Get the original exception that caused this exception. <code>null</code> is returned if there
         * were no original exception. In that case, there was a compilation error and the compiler has
         * returned with the exit code that can be obtained using <code>getCompilerExitCode</code> method.
         *
         * @see #getCompilerExitCode()
         */
        public Exception getOriginalException() {
            return originalException;
        }

        /**
         * Get the compiler exit code. If <code>0</code> is returned, this indicates that an exception was
         * thrown during compiler initialization, or inside the compiler itself. Use <code>getOriginalExcepion</code>
         * method to obtain that exception.
         *
         * @see #getOriginalException
         */
        public int getCompilerExitCode() {
            return compilerExitCode;
        }
    }

    /** Exception signalling a problem with reading project database file. */
    public static class PDBCorruptedException extends Exception {

        private static final long serialVersionUID = 1L;

        PDBCorruptedException(String msg) {
            super(msg);
        }
    }

    /** Exception signalling a problem when parsing a class file */
    public static class ClassFileParseException extends Exception {

        private static final long serialVersionUID = 1L;

        ClassFileParseException(String msg) {
            super(msg);
        }
    }

    /** Exception signalling that <b>jmake</b> was not requested to do any real work. */
    public static class NoActionRequestedException extends Exception {

        private static final long serialVersionUID = 1L;
    }

    /** Exception signalling that an invalid command line option has been passed to jmake. */
    public static class InvalidCmdOptionException extends Exception {

        private static final long serialVersionUID = 1L;

        InvalidCmdOptionException(String msg) {
            super(msg);
        }
    }

    /**
     * Exception signalling a problem (typically an I/O exception) when parsing a command line file
     * passed to <b>jmake</b>.
     */
    public static class CommandFileReadException extends Exception {

        private static final long serialVersionUID = 1L;

        CommandFileReadException(String msg) {
            super(msg);
        }
    }

    /**
     * Exception signalling that for some class the deduced name (that is, name based on the source file name and
     * directory) and the real name (the one read from the class file) are different.
     */
    public static class ClassNameMismatchException extends Exception {

        private static final long serialVersionUID = 1L;

        ClassNameMismatchException(String msg) {
            super(msg);
        }
    }

    /** Exception thrown if any specified source file has an invalid extension (not <code>.java</code> or <code>.jar</code>). */
    public static class InvalidSourceFileExtensionException extends Exception {

        private static final long serialVersionUID = 1L;

        InvalidSourceFileExtensionException(String msg) {
            super(msg);
        }
    }

    /** Exception thrown if a dependence of a class in a <code>JAR</code> file on a class with a <code>.java</code> source is detected. */
    public static class JarDependsOnSourceException extends Exception {

        private static final long serialVersionUID = 1L;

        JarDependsOnSourceException(String msg) {
            super(msg);
        }
    }

    /** Exception thrown if more than one entry for the same class is detected in the project */
    public static class DoubleEntryException extends Exception {

        private static final long serialVersionUID = 1L;

        DoubleEntryException(String msg) {
            super(msg);
        }
    }

    /** Exception thrown if an internal problem that should never happen is detected. */
    public static class InternalException extends Exception {

        private static final long serialVersionUID = 1L;

        InternalException(String msg) {
            super(msg);
        }
    }
}