Ignore:
Timestamp:
2012-01-21T12:07:57+01:00 (12 years ago)
Author:
simon04
Message:

remotecontrol: primt more helpful Bad Request errors, i.e., list available commands, or show missing parameter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java

    r4191 r4834  
    55
    66import java.util.HashMap;
     7import java.util.LinkedList;
     8import java.util.List;
    79import java.util.StringTokenizer;
    810
     
    1113import org.openstreetmap.josm.Main;
    1214import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault;
     15import org.openstreetmap.josm.tools.Utils;
    1316
    1417/**
     
    9194    }
    9295
    93     protected String[] getMandatoryParams()
    94     {
     96    public String[] getMandatoryParams() {
    9597        return null;
    9698    }
     
    169171        if(mandatory == null) return;
    170172
     173        List<String> missingKeys = new LinkedList<String>();
    171174        boolean error = false;
    172175        for (int i = 0; i < mandatory.length; ++i) {
     
    176179                error = true;
    177180                System.out.println("'" + myCommand + "' remote control request must have '" + key + "' parameter");
     181                missingKeys.add(key);
    178182            }
    179183        }
    180         if (error)
    181             throw new RequestHandlerBadRequestException();
     184        if (error) {
     185            throw new RequestHandlerBadRequestException(
     186                    "The following keys are mandatory, but have not been provided: "
     187                    + Utils.join(", ", missingKeys));
     188        }
    182189    }
    183190
     
    204211
    205212    public static class RequestHandlerException extends Exception {
     213
     214        public RequestHandlerException(String message) {
     215            super(message);
     216        }
     217
     218        public RequestHandlerException() {
     219        }
    206220    }
    207221
     
    210224
    211225    public static class RequestHandlerBadRequestException extends RequestHandlerException {
     226
     227        public RequestHandlerBadRequestException(String message) {
     228            super(message);
     229        }
    212230    }
    213231   
Note: See TracChangeset for help on using the changeset viewer.