@Override public boolean matchesSafely(Throwable item) { return item instanceof ParseException && matcher.matches(((ParseException) item).getCode()); }
@Override /* package */ void validateSaveEventually() throws ParseException { if (isDirty(KEY_PASSWORD)) { // TODO(mengyan): Unify the exception we throw when validate fails throw new ParseException( ParseException.OTHER_CAUSE, "Unable to saveEventually on a ParseUser with dirty password"); } }
@Test public void testGetSyncFail() { ParseException exception = new ParseException(ParseException.CONNECTION_FAILED, "error"); ParseConfigController controller = mockParseConfigControllerWithException(exception); ParseCorePlugins.getInstance().registerConfigController(controller); try { ParseConfig.get(); fail("Should throw an exception"); } catch (ParseException e) { verify(controller, times(1)).getAsync(anyString()); assertEquals(ParseException.CONNECTION_FAILED, e.getCode()); assertEquals("error", e.getMessage()); } }
@Override public void done(ParseConfig config, ParseException e) { assertEquals(ParseException.CONNECTION_FAILED, e.getCode()); assertEquals("error", e.getMessage()); done.release(); } });
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Test public void testGetInBackgroundFail() throws Exception { ParseException exception = new ParseException(ParseException.CONNECTION_FAILED, "error"); ParseConfigController controller = mockParseConfigControllerWithException(exception); ParseCorePlugins.getInstance().registerConfigController(controller); Task<ParseConfig> configTask = ParseConfig.getInBackground(); configTask.waitForCompletion(); verify(controller, times(1)).getAsync(anyString()); assertThat(configTask.getError(), instanceOf(ParseException.class)); assertEquals(ParseException.CONNECTION_FAILED, ((ParseException) configTask.getError()).getCode()); assertEquals("error", configTask.getError().getMessage()); }
@Override public void done(ParseException e) { if (isActivityDestroyed()) { return; } loadingFinish(); if (e == null) { instructionsTextView .setText(R.string.com_parse_ui_login_help_email_sent); emailField.setVisibility(View.INVISIBLE); submitButton .setText(R.string.com_parse_ui_login_help_login_again_button_label); emailSent = true; } else { debugLog(getString(R.string.com_parse_ui_login_warning_password_reset_failed) + e.toString()); if (e.getCode() == ParseException.INVALID_EMAIL_ADDRESS || e.getCode() == ParseException.EMAIL_NOT_FOUND) { showToast(R.string.com_parse_ui_invalid_email_toast); } else { showToast(R.string.com_parse_ui_login_help_submit_failed_unknown); } } } });
@Override public void done(ParseException e) { if (e == null) { // Add the latest results for this query to the cache. Log.d("PARSE_PIN_WIN", pinName); ParseObject.pinAllInBackground(pinName, data); } else { Log.d("PARSE_PIN_ERROR", e.toString()); } } });
public void done(List<ParseObject> networkList, ParseException e) { if (e == null) { for (int i = 0; i < networkList.size(); i++) { networks.add(networkList.get(i).getString("title")); Collections.sort(networks); } } else { Log.d("score", "Error: " + e.getMessage()); } } });
public Network getNetwork() { Network network = null; try { network = this.getParseObject(NETWORK_KEY).fetchIfNeeded(); } catch (ParseException e) { e.printStackTrace(); } return network; }
ParseTaskUtils.wait(Task.whenAll(tasks)); } catch (ParseException e) { assertTrue(e.getCause() instanceof AggregateException);
assertTrue(deleteTaskList.get(1).getError() instanceof ParseException); ParseException parseException = (ParseException) deleteTaskList.get(1).getError(); assertEquals(101, parseException.getCode()); assertEquals("Error", parseException.getMessage());
@Override public void done(ParseException e) { if (isActivityDestroyed()) { return; } if (e == null) { loadingFinish(); signupSuccess(); } else { loadingFinish(); if (e != null) { debugLog(getString(R.string.com_parse_ui_login_warning_parse_signup_failed) + e.toString()); switch (e.getCode()) { case ParseException.INVALID_EMAIL_ADDRESS: showToast(R.string.com_parse_ui_invalid_email_toast); break; case ParseException.USERNAME_TAKEN: showToast(R.string.com_parse_ui_username_taken_toast); break; case ParseException.EMAIL_TAKEN: showToast(R.string.com_parse_ui_email_taken_toast); break; default: showToast(R.string.com_parse_ui_signup_failed_unknown_toast); } } } } });
public void done(ParseException e) { if (e == null) { try { // [ ] TODO: auto subscribe user to features with auto subscribe true Intent i = new Intent(SignUpEmailActivity.this, UserProfileActivity.class); i.putExtra("Name", name); i.putExtra("Email", email); i.putExtra("Password", password); i.putExtra("userAns", userAns); startActivity(i); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); } catch (Exception ex) { } } else { // TODO: Provide feedback and next steps to user when creation fails Snackbar.make(msnackbar, R.string.user_creation_failed, Snackbar.LENGTH_LONG).show(); Log.d(getResources().getString(R.string.user_creation_failed_message), e.toString()); } } });
public void done(List<Feature> lFeatures, ParseException e) { if (e == null && lFeatures.size() > 0) { features.clear(); // this won't work // only add after feature item features.addAll(lFeatures); LocalDataStore.unpinAndRepin(lFeatures, LocalDataStore.FEATURES_PIN); } else { Log.d("Message", "Error: " + e.getMessage()); } listCounter++; } });
user = message.getParseUser(Message.USER_KEY).fetchIfNeeded(); } catch (ParseException e) { e.printStackTrace();
@Override public Integer call() throws Exception { JSONObject cached = ParseKeyValueCache.jsonFromKeyValueCache(cacheKey, state.maxCacheAge()); if (cached == null) { throw new ParseException(ParseException.CACHE_MISS, "results not cached"); } try { return cached.getInt("count"); } catch (JSONException e) { throw new ParseException(ParseException.CACHE_MISS, "the cache contains corrupted json"); } } }, Task.BACKGROUND_EXECUTOR);
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") @Override public Task<TResult> then(Task<TResult> task) { Exception error = task.getError(); if (error instanceof ParseException && ((ParseException) error).getCode() == ParseException.CONNECTION_FAILED) { return c.runFromCacheAsync(); } // Either the query succeeded, or there was an an error with the query, not the // network return task; } });
@SuppressWarnings("ThrowableResultOfMethodCallIgnored") public void test4XXThrowsException() throws Exception { ParseRequest.setDefaultInitialRetryDelay(1L); InputStream mockInputStream = new ByteArrayInputStream( "An Error occurred while saving".getBytes()); ParseHttpResponse mockResponse = new ParseHttpResponse.Builder() .setStatusCode(400) .setTotalSize(0L) .setReasonPhrase("Bad Request") .setContent(mockInputStream) .build(); ParseHttpClient mockHttpClient = mock(ParseHttpClient.class); when(mockHttpClient.execute(any(ParseHttpRequest.class))).thenReturn(mockResponse); ParseFileRequest request = new ParseFileRequest(ParseHttpRequest.Method.GET, "http://parse.com", null); Task<Void> task = request.executeAsync(mockHttpClient); task.waitForCompletion(); assertTrue(task.isFaulted()); assertTrue(task.getError() instanceof ParseException); ParseException error = (ParseException) task.getError(); assertEquals(error.getCode(), ParseException.CONNECTION_FAILED); assertTrue(error.getMessage().contains("Download from file server")); } }
public void done(List<Post> listPosts, ParseException e) { if (e != null) { Log.d("Message", "Error: " + e.getMessage()); } else if (listPosts != null) { posts.clear(); posts.addAll(listPosts); LocalDataStore.unpinAndRepin(listPosts, LocalDataStore.POSTS_PIN); } listCounter++; } });