/** * There are situations that the downstream service returns an error status response and we just * want to bubble up to the caller and eventually to the original caller. * * @param exchange HttpServerExchange * @param status error status */ default void setExchangeStatus(HttpServerExchange exchange, Status status) { exchange.setStatusCode(status.getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); status.setDescription(status.getDescription().replaceAll("\\\\", "\\\\\\\\")); exchange.getResponseSender().send(status.toString()); StackTraceElement[] elements = Thread.currentThread().getStackTrace(); logger.error(status.toString() + " at " + elements[2].getClassName() + "." + elements[2].getMethodName() + "(" + elements[2].getFileName() + ":" + elements[2].getLineNumber() + ")"); } }
/** * This method is used to construct a standard error status in JSON format from an error code. * * @param exchange HttpServerExchange * @param code error code * @param args arguments for error description */ default void setExchangeStatus(HttpServerExchange exchange, String code, final Object... args) { Status status = new Status(code, args); if(status.getStatusCode() == 0) { // There is no entry in status.yml for this particular error code. status = new Status(ERROR_NOT_DEFINED, code); } exchange.setStatusCode(status.getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); status.setDescription(status.getDescription().replaceAll("\\\\", "\\\\\\\\")); exchange.getResponseSender().send(status.toString()); StackTraceElement[] elements = Thread.currentThread().getStackTrace(); logger.error(status.toString() + " at " + elements[2].getClassName() + "." + elements[2].getMethodName() + "(" + elements[2].getFileName() + ":" + elements[2].getLineNumber() + ")"); }
switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
@Override public String toString() { if(statusSerializer != null) { return statusSerializer.serializeStatus(this); } else { return "{\"statusCode\":" + getStatusCode() + ",\"code\":\"" + getCode() + "\",\"message\":\"" + getMessage() + "\",\"description\":\"" + getDescription() + "\",\"severity\":\"" + getSeverity() + "\"}"; } } }
final Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
final Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
final LocationSettingsStates state = result .getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
exchange.setStatusCode(fe.getStatus().getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); exchange.getResponseSender().send(fe.getStatus().toString()); if(e instanceof ApiException) { ApiException ae = (ApiException)e; exchange.setStatusCode(ae.getStatus().getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); exchange.getResponseSender().send(ae.getStatus().toString());
final Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
public void onResult(LocationSettingsResult result) { final Status status = result.getStatus(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: Log.i(TAG, "All location settings are satisfied.");
final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS:
Nearby.Messages.publish(mNearbyApi, mMessage) .setResultCallback(new ResultCallback<Status>() { @Override public void onResult(@NonNull Status status) { Log.d(TAG, "Nearby publish result: " + getStatusCodeString(status.getStatusCode())); if (status.getStatusCode() > 0) { Intent intent = ResolveErrorActivity.buildIntent(getContext(), status); startActivityForResult(intent, ResolveErrorActivity.REQUEST_RESOLVE_ERROR); } } });
PendingResult<Status> pendingResult = LocationServices.GeofencingApi.removeGeofences(mGoogleApiClient, mCurrentGeofenceIds); pendingResult.setResultCallback(new ResultCallback<Status>() { @Override public void onResult(Status status) { onRemoveGeofencesByRequestIdsResult(status.getStatusCode()); } });
Log.d("result=", String.valueOf(result)); if (result.isSuccess()) { GoogleSignInAccount acct = result.getSignInAccount(); try { Log.i("Signin", acct.getDisplayName()); } catch (NullPointerException e) { Log.d(TAG, "Error retrieving some account information"); } } else { Status status = result.getStatus(); int statusCode = status.getStatusCode(); Log.d("StatusCode", String.valueOf(statusCode)); if (statusCode == GoogleSignInStatusCodes.SIGN_IN_CANCELLED) { } else if (statusCode == GoogleSignInStatusCodes.SIGN_IN_FAILED) { } else { } }
LocationSettingsStates locationSettingsStates = locationSettingsResult.getLocationSettingsStates(); if (!locationSettingsStates.isGpsPresent() || !locationSettingsStates.isGpsUsable()) { Status status = locationSettingsResult.getStatus(); if (status.getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) { try { status.startResolutionForResult(StilActivity.this, REQUEST_CHECK_SETTINGS); } catch (IntentSender.SendIntentException th) { Log.e(TAG, "Error opening settings activity.", th); } } }
/** * There are situations that the downstream service returns an error status response and we just * want to bubble up to the caller and eventually to the original caller. * * @param exchange HttpServerExchange * @param status error status */ default void setExchangeStatus(HttpServerExchange exchange, Status status) { exchange.setStatusCode(status.getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); status.setDescription(status.getDescription().replaceAll("\\\\", "\\\\\\\\")); exchange.getResponseSender().send(status.toString()); StackTraceElement[] elements = Thread.currentThread().getStackTrace(); logger.error(status.toString() + " at " + elements[2].getClassName() + "." + elements[2].getMethodName() + "(" + elements[2].getFileName() + ":" + elements[2].getLineNumber() + ")"); } }
/** * This method is used to construct a standard error status in JSON format from an error code. * * @param exchange HttpServerExchange * @param code error code * @param args arguments for error description */ default void setExchangeStatus(HttpServerExchange exchange, String code, final Object... args) { Status status = new Status(code, args); if(status.getStatusCode() == 0) { // There is no entry in status.yml for this particular error code. status = new Status(ERROR_NOT_DEFINED, code); } exchange.setStatusCode(status.getStatusCode()); exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "application/json"); status.setDescription(status.getDescription().replaceAll("\\\\", "\\\\\\\\")); exchange.getResponseSender().send(status.toString()); StackTraceElement[] elements = Thread.currentThread().getStackTrace(); logger.error(status.toString() + " at " + elements[2].getClassName() + "." + elements[2].getMethodName() + "(" + elements[2].getFileName() + ":" + elements[2].getLineNumber() + ")"); }
@Override public String toString() { if(statusSerializer != null) { return statusSerializer.serializeStatus(this); } else { return "{\"statusCode\":" + getStatusCode() + ",\"code\":\"" + getCode() + "\",\"message\":\"" + getMessage() + "\",\"description\":\"" + getDescription() + "\",\"severity\":\"" + getSeverity() + "\"}"; } } }