本文整理汇总了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());
}