Changeset 14340 in josm


Ignore:
Timestamp:
2018-10-17T02:30:45+02:00 (6 years ago)
Author:
Don-vip
Message:

fix #13777 - allow to copy/paste error message from most of our error dialogs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/ExceptionDialogUtil.java

    r14153 r14340  
    4242    }
    4343
     44    private static int showErrorDialog(String msg, String title, String helpTopic) {
     45        return HelpAwareOptionPane.showOptionDialog(
     46                MainApplication.getMainFrame(),
     47                new HtmlPanel(msg),
     48                title,
     49                JOptionPane.ERROR_MESSAGE,
     50                helpTopic
     51        );
     52    }
     53
    4454    /**
    4555     * handles an exception caught during OSM API initialization
     
    4858     */
    4959    public static void explainOsmApiInitializationException(OsmApiInitializationException e) {
    50         HelpAwareOptionPane.showOptionDialog(
    51                 MainApplication.getMainFrame(),
     60        showErrorDialog(
    5261                ExceptionUtil.explainOsmApiInitializationException(e),
    5362                tr("Error"),
    54                 JOptionPane.ERROR_MESSAGE,
    5563                ht("/ErrorMessages#OsmApiInitializationException")
    5664        );
     
    6371     */
    6472    public static void explainChangesetClosedException(ChangesetClosedException e) {
    65         HelpAwareOptionPane.showOptionDialog(
    66                 MainApplication.getMainFrame(),
     73        showErrorDialog(
    6774                ExceptionUtil.explainChangesetClosedException(e),
    6875                tr("Error"),
    69                 JOptionPane.ERROR_MESSAGE,
    7076                ht("/Action/Upload#ChangesetClosed")
    7177        );
     
    7884     */
    7985    public static void explainPreconditionFailed(OsmApiException e) {
    80         HelpAwareOptionPane.showOptionDialog(
    81                 MainApplication.getMainFrame(),
     86        showErrorDialog(
    8287                ExceptionUtil.explainPreconditionFailed(e),
    8388                tr("Precondition violation"),
    84                 JOptionPane.ERROR_MESSAGE,
    8589                ht("/ErrorMessages#OsmApiException")
    8690        );
     
    104108     * @param e the exception
    105109     */
    106 
    107110    public static void explainSecurityException(OsmTransferException e) {
    108         HelpAwareOptionPane.showOptionDialog(
    109                 MainApplication.getMainFrame(),
     111        showErrorDialog(
    110112                ExceptionUtil.explainSecurityException(e),
    111113                tr("Security exception"),
    112                 JOptionPane.ERROR_MESSAGE,
    113114                ht("/ErrorMessages#SecurityException")
    114115        );
     
    122123     * @param e the exception
    123124     */
    124 
    125125    public static void explainNestedSocketException(OsmTransferException e) {
    126         HelpAwareOptionPane.showOptionDialog(
    127                 MainApplication.getMainFrame(),
     126        showErrorDialog(
    128127                ExceptionUtil.explainNestedSocketException(e),
    129128                tr("Network exception"),
    130                 JOptionPane.ERROR_MESSAGE,
    131129                ht("/ErrorMessages#NestedSocketException")
    132130        );
     
    140138     * @param e the exception
    141139     */
    142 
    143140    public static void explainNestedIOException(OsmTransferException e) {
    144         HelpAwareOptionPane.showOptionDialog(
    145                 MainApplication.getMainFrame(),
     141        showErrorDialog(
    146142                ExceptionUtil.explainNestedIOException(e),
    147143                tr("IO Exception"),
    148                 JOptionPane.ERROR_MESSAGE,
    149144                ht("/ErrorMessages#NestedIOException")
    150145        );
     
    158153     */
    159154    public static void explainNestedIllegalDataException(OsmTransferException e) {
    160         HelpAwareOptionPane.showOptionDialog(
    161                 MainApplication.getMainFrame(),
     155        showErrorDialog(
    162156                ExceptionUtil.explainNestedIllegalDataException(e),
    163157                tr("Illegal Data"),
    164                 JOptionPane.ERROR_MESSAGE,
    165158                ht("/ErrorMessages#IllegalDataException")
    166159        );
     
    175168     */
    176169    public static void explainNestedOfflineAccessException(OsmTransferException e) {
    177         HelpAwareOptionPane.showOptionDialog(
    178                 MainApplication.getMainFrame(),
     170        showErrorDialog(
    179171                ExceptionUtil.explainOfflineAccessException(e),
    180172                tr("Offline mode"),
    181                 JOptionPane.ERROR_MESSAGE,
    182173                ht("/ErrorMessages#OfflineAccessException")
    183174        );
     
    203194     * @param e the exception
    204195     */
    205 
    206196    public static void explainInternalServerError(OsmTransferException e) {
    207         HelpAwareOptionPane.showOptionDialog(
    208                 MainApplication.getMainFrame(),
     197        showErrorDialog(
    209198                ExceptionUtil.explainInternalServerError(e),
    210199                tr("Internal Server Error"),
    211                 JOptionPane.ERROR_MESSAGE,
    212200                ht("/ErrorMessages#InternalServerError")
    213201        );
     
    221209     */
    222210    public static void explainBadRequest(OsmApiException e) {
    223         HelpAwareOptionPane.showOptionDialog(
    224                 MainApplication.getMainFrame(),
     211        showErrorDialog(
    225212                ExceptionUtil.explainBadRequest(e),
    226213                tr("Bad Request"),
    227                 JOptionPane.ERROR_MESSAGE,
    228214                ht("/ErrorMessages#BadRequest")
    229215        );
     
    237223     */
    238224    public static void explainNotFound(OsmApiException e) {
    239         HelpAwareOptionPane.showOptionDialog(
    240                 MainApplication.getMainFrame(),
     225        showErrorDialog(
    241226                ExceptionUtil.explainNotFound(e),
    242227                tr("Not Found"),
    243                 JOptionPane.ERROR_MESSAGE,
    244228                ht("/ErrorMessages#NotFound")
    245229        );
     
    252236     */
    253237    public static void explainConflict(OsmApiException e) {
    254         HelpAwareOptionPane.showOptionDialog(
    255                 MainApplication.getMainFrame(),
     238        showErrorDialog(
    256239                ExceptionUtil.explainConflict(e),
    257240                tr("Conflict"),
    258                 JOptionPane.ERROR_MESSAGE,
    259241                ht("/ErrorMessages#Conflict")
    260242        );
     
    275257        }
    276258
    277         HelpAwareOptionPane.showOptionDialog(
    278                 MainApplication.getMainFrame(),
     259        showErrorDialog(
    279260                msg,
    280261                tr("Authentication failed"),
    281                 JOptionPane.ERROR_MESSAGE,
    282262                ht("/ErrorMessages#AuthenticationFailed")
    283263        );
     
    312292        }
    313293
    314         HelpAwareOptionPane.showOptionDialog(
    315                 MainApplication.getMainFrame(),
     294        showErrorDialog(
    316295                msg,
    317296                tr("Authorisation Failed"),
    318                 JOptionPane.ERROR_MESSAGE,
    319297                ht("/ErrorMessages#AuthorizationFailed")
    320298        );
     
    328306     */
    329307    public static void explainClientTimeout(OsmApiException e) {
    330         HelpAwareOptionPane.showOptionDialog(
    331                 MainApplication.getMainFrame(),
     308        showErrorDialog(
    332309                ExceptionUtil.explainClientTimeout(e),
    333310                tr("Client Time Out"),
    334                 JOptionPane.ERROR_MESSAGE,
    335311                ht("/ErrorMessages#ClientTimeOut")
    336312        );
     
    344320     */
    345321    public static void explainBandwidthLimitExceeded(OsmApiException e) {
    346         HelpAwareOptionPane.showOptionDialog(
    347                 MainApplication.getMainFrame(),
     322        showErrorDialog(
    348323                ExceptionUtil.explainBandwidthLimitExceeded(e),
    349324                tr("Bandwidth Limit Exceeded"),
    350                 JOptionPane.ERROR_MESSAGE,
    351325                ht("/ErrorMessages#BandwidthLimit")
    352326        );
     
    382356     */
    383357    public static void explainMissingOAuthAccessTokenException(MissingOAuthAccessTokenException e) {
    384         HelpAwareOptionPane.showOptionDialog(
    385                 MainApplication.getMainFrame(),
     358        showErrorDialog(
    386359                ExceptionUtil.explainMissingOAuthAccessTokenException(e),
    387360                tr("Authentication failed"),
    388                 JOptionPane.ERROR_MESSAGE,
    389361                ht("/ErrorMessages#MissingOAuthAccessToken")
    390362        );
     
    399371     */
    400372    public static void explainNestedUnkonwnHostException(OsmTransferException e) {
    401         HelpAwareOptionPane.showOptionDialog(
    402                 MainApplication.getMainFrame(),
     373        showErrorDialog(
    403374                ExceptionUtil.explainNestedUnknownHostException(e),
    404375                tr("Unknown host"),
    405                 JOptionPane.ERROR_MESSAGE,
    406376                ht("/ErrorMessages#UnknownHost")
    407377        );
     
    502472     */
    503473    public static void explainGoneForUnknownPrimitive(OsmApiException e) {
    504         HelpAwareOptionPane.showOptionDialog(
    505                 MainApplication.getMainFrame(),
     474        showErrorDialog(
    506475                ExceptionUtil.explainGoneForUnknownPrimitive(e),
    507476                tr("Object deleted"),
    508                 JOptionPane.ERROR_MESSAGE,
    509477                ht("/ErrorMessages#GoneForUnknownPrimitive")
    510478        );
Note: See TracChangeset for help on using the changeset viewer.