本文整理匯總了Java中com.parse.ParseException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java ParseException.getMessage方法的具體用法?Java ParseException.getMessage怎麽用?Java ParseException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.parse.ParseException
的用法示例。
在下文中一共展示了ParseException.getMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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";
}
}