Translate some exception message.

pull/172/head
ruibaby 2019-05-31 17:57:49 +08:00
parent 73c6f75469
commit fbaff2883b
11 changed files with 12 additions and 18 deletions

View File

@ -57,11 +57,7 @@ public class CommonController implements ErrorController {
}
}
if (statusCode == 500) {
return "redirect:/500";
} else {
return "redirect:/404";
}
return statusCode == 500 ? "redirect:/500" : "redirect:/404";
}
/**

View File

@ -62,7 +62,7 @@ public class AliYunFileHandler implements FileHandler {
// Upload
PutObjectResult putObjectResult = ossClient.putObject(ossBucketName, upFilePath, file.getInputStream());
if (putObjectResult == null) {
throw new FileOperationException("Failed to upload file " + file.getOriginalFilename() + " to AliYun " + upFilePath);
throw new FileOperationException("上传附件 " + file.getOriginalFilename() + " 到阿里云失败 ");
}
// Response result

View File

@ -162,7 +162,7 @@ public class LocalFileHandler implements FileHandler {
return uploadResult;
} catch (IOException e) {
log.error("Failed to upload file to local: " + uploadPath, e);
throw new ServiceException("Failed to upload file to local").setErrorData(uploadPath);
throw new ServiceException("上传附件失败").setErrorData(uploadPath);
}
}

View File

@ -121,7 +121,7 @@ public class QnYunFileHandler implements FileHandler {
log.error("QnYun error response: [{}]", ((QiniuException) e).response);
}
throw new FileOperationException("Failed to upload file " + file.getOriginalFilename() + " to QnYun", e);
throw new FileOperationException("上传附件 " + file.getOriginalFilename() + " 到七牛云失败", e);
}
}

View File

@ -65,7 +65,7 @@ public class SmmsFileHandler implements FileHandler {
body.add("smfile", new HttpClientUtils.MultipartFileResource(file.getBytes(), file.getOriginalFilename()));
} catch (IOException e) {
log.error("Failed to get file input stream", e);
throw new FileOperationException("Failed to upload " + file.getOriginalFilename() + " file", e);
throw new FileOperationException("上传附件 " + file.getOriginalFilename() + " 到 SM.MS 失败", e);
}
body.add("ssl", false);

View File

@ -91,7 +91,7 @@ public class UpYunFileHandler implements FileHandler {
return uploadResult;
} catch (Exception e) {
throw new FileOperationException("Failed to upload file " + file.getOriginalFilename() + " to UpYun", e);
throw new FileOperationException("上传附件 " + file.getOriginalFilename() + " 到又拍云失败", e);
}
}

View File

@ -342,7 +342,7 @@ public abstract class BasePostServiceImpl<POST extends BasePost> extends Abstrac
}
if (exist) {
throw new AlreadyExistsException("The post url " + post.getUrl() + " has been exist");
throw new AlreadyExistsException("文章路径 " + post.getUrl() + " 已存在");
}
}

View File

@ -53,7 +53,7 @@ public class CategoryServiceImpl extends AbstractCrudService<Category, Integer>
if (count > 0) {
log.error("Category has exist already: [{}]", category);
throw new AlreadyExistsException("The category has exist already");
throw new AlreadyExistsException("该分类已存在");
}
// Check parent id

View File

@ -171,7 +171,7 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
}
if (exist) {
throw new AlreadyExistsException("The menu name " + menu.getName() + " already exists");
throw new AlreadyExistsException("菜单 " + menu.getName() + " 已存在");
}
}
}

View File

@ -42,7 +42,7 @@ public class TagServiceImpl extends AbstractCrudService<Tag, Integer> implements
if (count > 0) {
// If the tag has exist already
throw new AlreadyExistsException("The tag has already exist").setErrorData(tag);
throw new AlreadyExistsException("该标签已存在").setErrorData(tag);
}
// Get tag name

View File

@ -3,12 +3,10 @@ package run.halo.app.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.MergeCommand;
import org.eclipse.jgit.api.PullResult;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.merge.MergeStrategy;
import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.URIish;
import org.springframework.context.ApplicationEventPublisher;
@ -371,7 +369,7 @@ public class ThemeServiceImpl implements ThemeService {
Assert.notNull(file, "Multipart file must not be null");
if (!StringUtils.endsWithIgnoreCase(file.getOriginalFilename(), ".zip")) {
throw new UnsupportedMediaTypeException("Unsupported theme media type: " + file.getContentType()).setErrorData(file.getOriginalFilename());
throw new UnsupportedMediaTypeException("不支持的文件类型: " + file.getContentType()).setErrorData(file.getOriginalFilename());
}
ZipInputStream zis = null;
@ -395,7 +393,7 @@ public class ThemeServiceImpl implements ThemeService {
// Go to the base folder and add the theme into system
return add(FileUtils.skipZipParentFolder(themeTempPath));
} catch (IOException e) {
throw new ServiceException("Failed to upload theme file: " + file.getOriginalFilename(), e);
throw new ServiceException("上传主题失败: " + file.getOriginalFilename(), e);
} finally {
// Close zip input stream
FileUtils.closeQuietly(zis);