本文整理匯總了Java中com.google.api.client.googleapis.json.GoogleJsonResponseException.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java GoogleJsonResponseException.getMessage方法的具體用法?Java GoogleJsonResponseException.getMessage怎麽用?Java GoogleJsonResponseException.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.api.client.googleapis.json.GoogleJsonResponseException
的用法示例。
在下文中一共展示了GoogleJsonResponseException.getMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertException
import com.google.api.client.googleapis.json.GoogleJsonResponseException; //導入方法依賴的package包/類
private Exception convertException(Exception e) {
logDebug("Exception: " + e.toString());
e.printStackTrace();
if (UserRecoverableAuthIOException.class.isAssignableFrom(e.getClass()))
{
logDebug("clearing account data.");
//this is not really nice because it removes data from the cache which might still be valid but we don't have the account name here...
mAccountData.clear();
}
if (GoogleJsonResponseException.class.isAssignableFrom(e.getClass()) )
{
GoogleJsonResponseException jsonEx = (GoogleJsonResponseException)e;
if (jsonEx.getDetails().getCode() == 404)
return new FileNotFoundException(jsonEx.getMessage());
}
return e;
}
示例2: readBlob
import com.google.api.client.googleapis.json.GoogleJsonResponseException; //導入方法依賴的package包/類
/**
* Returns an {@link java.io.InputStream} for a given blob
*
* @param blobName name of the blob
* @return an InputStream
*/
InputStream readBlob(String blobName) throws IOException {
try {
return SocketAccess.doPrivilegedIOException(() -> {
Storage.Objects.Get object = client.objects().get(bucket, blobName);
return object.executeMediaAsInputStream();
});
} catch (GoogleJsonResponseException e) {
GoogleJsonError error = e.getDetails();
if ((e.getStatusCode() == HTTP_NOT_FOUND) || ((error != null) && (error.getCode() == HTTP_NOT_FOUND))) {
throw new NoSuchFileException(e.getMessage());
}
throw e;
}
}
示例3: from
import com.google.api.client.googleapis.json.GoogleJsonResponseException; //導入方法依賴的package包/類
/**
* Static builder to construct a {@code GoogleApiException} from a {@link
* GoogleJsonResponseException}
*
* @param exception a GoogleJsonResponseException that was thrown by a Google API call
*/
public static GoogleApiException from(GoogleJsonResponseException exception) {
String message =
exception.getDetails() != null
? exception.getDetails().getMessage()
: exception.getMessage();
return new GoogleApiException(message, exception, exception.getStatusCode());
}