src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/OptionException.java
author jlahoda
Fri, 09 Mar 2018 09:42:10 +0100
changeset 49197 cc2673fa8c20
parent 47216 71c04702a3d5
permissions -rw-r--r--
8187950: javax.lang.model APIs throws CompletionFailure or a subtype of CompletionFailure. Summary: Catching CompletionFailures that would be thrown to API clients, and re-completing the symbols again when javac itself needs it. Reviewed-by: cushon, jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41451
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     1
/*
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     4
 *
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    10
 *
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    15
 * accompanied this code).
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    16
 *
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    20
 *
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    23
 * questions.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    24
 */
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    25
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    26
package jdk.javadoc.internal.tool;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    27
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    28
import jdk.javadoc.internal.tool.Main.Result;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    29
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    30
/**
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    31
 * Provides a general mechanism for the javadoc tool to indicate an option
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    32
 * decoding issue.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    33
 *
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    34
 * <p><b>This is NOT part of any supported API.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    35
 * If you write code that depends on this, you do so at your own risk.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    36
 * This code and its internal interfaces are subject to change or
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    37
 * deletion without notice.</b>
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    38
 */
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    39
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    40
class OptionException extends Exception {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    41
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    42
    private static final long serialVersionUID = 0;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    43
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    44
    public final Result result;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    45
    public final String message;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    46
    public final Runnable m;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    47
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    48
    /**
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    49
     * Constructs an object with a result, runnable and a message
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    50
     * to be printed out by the catcher. The runnable can be invoked
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    51
     * by the catcher to display the usage text.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    52
     * @param result the exit code
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    53
     * @param method the method to invoke
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    54
     * @param message the detailed message
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    55
     */
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    56
    public OptionException(Result result, Runnable method, String message) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    57
        this.result = result;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    58
        this.m = method;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    59
        this.message = message;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    60
        if (result == null || result.isOK() || method == null || message == null) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    61
            throw new AssertionError("result == null || result.isOK() || " +
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    62
                    "method == null || message == null");
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    63
        }
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    64
    }
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    65
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    66
    /**
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    67
     * Constructs an object with a result and a runnable.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    68
     * The runnable can be invoked by the catcher to display the usage text.
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    69
     * @param result the exit code
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    70
     * @param method the method to invoke
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    71
     */
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    72
    public OptionException(Result result, Runnable method) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    73
        this.result = result;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    74
        this.m = method;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    75
        this.message = null;
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    76
        if (result == null || method == null) {
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    77
            throw new AssertionError("result == null || method == null");
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    78
        }
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    79
    }
a847c7aa25a7 8151102: Cleanup javadoc exception handling
ksrini
parents:
diff changeset
    80
}