本文整理汇总了Java中com.parse.ParseException.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java ParseException.getCode方法的具体用法?Java ParseException.getCode怎么用?Java ParseException.getCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.parse.ParseException
的用法示例。
在下文中一共展示了ParseException.getCode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doInBackground
import com.parse.ParseException; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
if (!mNetworkCallback.checkNetworkStatus()){
return -1;
}
try { //Query Parse for the user's pings
ParseQuery<ParseObject> query = ParseQuery.getQuery("Pings");
query.whereEqualTo("User", user);
query.orderByDescending("createdAt");
pingsList = query.find();
} catch (ParseException e) {return e.getCode();}//return exception code
return 0;//no issues
}
示例2: doInBackground
import com.parse.ParseException; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
if (!mCallback.checkNetworkStatus())
return -1;//no internet, couldn't even attempt to login
ParseUser.logOut();//make sure the user is logged out first
try {
user.signUp();
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user",ParseUser.getCurrentUser());
installation.saveInBackground();
} catch (ParseException e) {return e.getCode();}//return exception code
return 0;//no issues
}
示例3: doInBackground
import com.parse.ParseException; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
if (!mCallback.checkNetworkStatus())
return -1;//no internet, couldn't even attempt to login
ParseUser.logOut();//make sure the user is logged out first
try {
ParseUser.logIn(email,pass);
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("user",ParseUser.getCurrentUser());
installation.saveInBackground();
} catch (ParseException e) {return e.getCode();}//return exception code
return 0;//no issues
}
示例4: doInBackground
import com.parse.ParseException; //导入方法依赖的package包/类
@Override
protected Integer doInBackground(String... params) {
try { //Query Parse for the user's pings
ParseQuery<ParseObject> query = ParseQuery.getQuery("FAQ_Category");
categoryList = new ArrayList<ParseObject>(query.find());
for (ParseObject category: categoryList) {
ArrayList<ParseObject> questionQuery = new ArrayList<ParseObject>(category.getRelation("Questions").getQuery().find());
//Filler
questionsList.add(questionQuery);
}
} catch (ParseException e) {return e.getCode();}//return exception code
return 0;//no issues
}
示例5: onSnackListUpdateComplete
import com.parse.ParseException; //导入方法依赖的package包/类
@Override
public void onSnackListUpdateComplete(ParseException e) {
// Start the login activity if the session token is invalid.
if(e != null && e.getCode() == ParseException.INVALID_SESSION_TOKEN){
if(myActivity != null){
Intent startLoginIntent = new Intent(myActivity, LoginActivity.class);
ParseUser.logOutInBackground();
myActivity.finish();
startActivity(startLoginIntent);
}
}
adapter.notifyDataSetChanged();
if(progressOverlay != null){
progressOverlay.setVisibility(View.GONE);
}
// Show the help message if appropriate.
// That is, if we haven't already showed it for the current user this session and the
// current user has zero entries. Only show the help message if the SnackList is pointing
// at the current user.
if(lastShowedHelpFor != ParseUser.getCurrentUser()
&& !showingHelp && SnackList.getInstance().size() == 0
&& ParseUser.getCurrentUser().equals(SnackList.getInstance().getUser())){
try{
showHelpMessage();
} catch(IllegalStateException ignored){
// In the case that onSaveInstanceState has been already been called, we ignore
// the exception.
}
}
}
示例6: getErrorMessage
import com.parse.ParseException; //导入方法依赖的package包/类
/**
* Tries to determine a friendly error message to display to the user, given a ParseException.
*
* @param e The exception.
*/
public static String getErrorMessage(ParseException e){
if(e != null){
switch(e.getCode()){
case CONNECTION_FAILED:
return "Connection failed";
case USERNAME_MISSING:
return "Username is missing";
case PASSWORD_MISSING:
return "Password is missing";
case EMAIL_MISSING:
return "Email is missing";
case USERNAME_TAKEN:
return "Username is taken";
case EMAIL_TAKEN:
return "Email is taken";
case TIMEOUT:
return "Request timed out";
default:
// If the default exception message isn't null, return it.
String exceptionMessage = e.getMessage();
if(exceptionMessage != null){
return exceptionMessage;
}
// Otherwise, check the cause's message
else{
Throwable cause;
String causeMessage;
cause = e.getCause();
// If the cause isn't null, get its message. Otherwise, set causeMessage to null
causeMessage = (cause == null) ? null : cause.getMessage();
// If the cause message isn't null, return it.
// Otherwise, just return the exception's error code.
if(causeMessage != null){
return String.format("%s (%d)", causeMessage, e.getCode());
} else{
return String.format("Error (%d)", e.getCode());
}
}
}
} else{
return "No error";
}
}