Skip to content

Commit 501853f

Browse files
author
Devendra
committed
handling 404
1 parent 5dd7784 commit 501853f

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

109 Bytes
Binary file not shown.

‎java/src1/com/pubnub/api/HttpClientCore.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public synchronized HttpResponse fetch(String url, Hashtable headers)
171171
throw new PubnubException(getErrorObject(PNERROBJ_READINPUT, url));
172172
}
173173

174-
log.verbose("URL = " + url + " : RESPONSE = " + page);
174+
log.verbose("URL = " + url + ", Status Code : " + rc + ", : RESPONSE = " + page);
175175
switch (rc) {
176176
case HttpURLConnection.HTTP_FORBIDDEN:
177177
throw new PubnubException(getErrorObject(PNERROBJ_FORBIDDEN, page));
@@ -199,6 +199,8 @@ public synchronized HttpResponse fetch(String url, Hashtable headers)
199199
throw new PubnubException(getErrorObject(PNERROBJ_GATEWAY_TIMEOUT, url));
200200
case HttpURLConnection.HTTP_INTERNAL_ERROR:
201201
throw new PubnubException(getErrorObject(PNERROBJ_INTERNAL_ERROR, url + " : " + rc));
202+
case HttpURLConnection.HTTP_NOT_FOUND:
203+
throw new PubnubException(getErrorObject(PNERROBJ_NOT_FOUND_ERROR, url + " : " + rc));
202204
default:
203205
break;
204206
}

‎java/srcPubnubApi/com/pubnub/api/PubnubError.java‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ public class PubnubError {
176176

177177

178178
public static final int PNERR_HTTP_RC_ERROR = 128;
179-
179+
/**
180+
* Pubnub server or intermediate server returned HTTP 404 unauthorized status code
181+
*
182+
*/
183+
public static final int PNERR_NOT_FOUND = 129;
180184

181185

182186
// Error Objects
@@ -369,9 +373,16 @@ public class PubnubError {
369373
static final PubnubError PNERROBJ_5075_NETWORK_ERROR =
370374
new PubnubError (
371375
PNERR_NETWORK_ERROR ,
372-
"Netowork Error. " +
376+
"Network Error. " +
373377
"Please verify if network is reachable."
374378
);
379+
static final PubnubError PNERROBJ_NOT_FOUND_ERROR =
380+
new PubnubError (
381+
PNERR_NOT_FOUND ,
382+
"Page Not Found" +
383+
"Please verify if network is reachable." +
384+
"Please contact support with error details."
385+
);
375386

376387

377388
public final int errorCode;

0 commit comments

Comments
 (0)