Changeset 216 in josm


Ignore:
Timestamp:
2007-04-10T14:37:17+02:00 (17 years ago)
Author:
imi
Message:
  • added nicer error messages from OSM server (thanks "anonymous" from ticket #126)
Location:
src/org/openstreetmap/josm/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/org/openstreetmap/josm/io/OsmServerWriter.java

    r203 r216  
    150150         *              <code>false</code>, if only the id is encoded.
    151151         */
    152         @SuppressWarnings("unchecked")
    153152        private void sendRequest(String requestMethod, String urlSuffix,
    154153                        OsmPrimitive osm, boolean addBody) {
     
    183182                                return; // everything fine.. was already deleted.
    184183                        if (retCode != 200) {
     184                                // Look for a detailed error message from the server
     185                                if (activeConnection.getHeaderField("Error") != null)
     186                                        retMsg += "\n" + activeConnection.getHeaderField("Error");
     187
     188                                // Report our error
    185189                                ByteArrayOutputStream o = new ByteArrayOutputStream();
    186190                                OsmWriter.output(o, new OsmWriter.Single(osm, true));
  • src/org/openstreetmap/josm/io/ProgressInputStream.java

    r160 r216  
    1919        private PleaseWaitDialog pleaseWaitDlg;
    2020
    21         public ProgressInputStream(URLConnection con, PleaseWaitDialog pleaseWaitDlg) throws IOException {
     21        public class OsmServerException extends IOException {
     22                private OsmServerException(String e) {
     23                        super(e);
     24                }
     25        }
     26
     27        public ProgressInputStream(URLConnection con, PleaseWaitDialog pleaseWaitDlg) throws IOException, OsmServerException {
    2228                this.connection = con;
    23                 this.in = con.getInputStream();
     29
     30                try {
     31                        this.in = con.getInputStream();
     32                } catch (IOException e) {
     33                        if (con.getHeaderField("Error") != null)
     34                                throw new OsmServerException(con.getHeaderField("Error"));
     35                        throw e;
     36                }
     37
    2438                int contentLength = con.getContentLength();
    2539                this.pleaseWaitDlg = pleaseWaitDlg;
Note: See TracChangeset for help on using the changeset viewer.