Translate some exception messgae.

pull/174/head
ruibaby 2019-06-01 16:53:46 +08:00
parent b03ab69acf
commit 6eb8af9e94
7 changed files with 12 additions and 12 deletions

View File

@ -50,7 +50,7 @@ public class MainController {
@GetMapping("/avatar")
public void avatar(HttpServletResponse response) throws IOException {
User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("Can not find blog owner"));
User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("找不到博主信息"));
if (StringUtils.isNotEmpty(user.getAvatar())) {
response.sendRedirect(user.getAvatar());
}

View File

@ -65,7 +65,7 @@ public class CommentEventListener {
return;
}
User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("Can not find blog owner"));
User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("找不到博主信息"));
Map<String, Object> data = new HashMap<>();

View File

@ -98,7 +98,7 @@ public class AdminAuthenticationFilter extends AbstractAuthenticationFilter {
Optional<Integer> optionalUserId = cacheStore.getAny(SecurityUtils.buildTokenAccessKey(token), Integer.class);
if (!optionalUserId.isPresent()) {
getFailureHandler().onFailure(request, response, new AuthenticationException("The token has been expired or not exist").setErrorData(token));
getFailureHandler().onFailure(request, response, new AuthenticationException("Token 已过期或不存在").setErrorData(token));
return;
}

View File

@ -77,7 +77,7 @@ public abstract class BasePostServiceImpl<POST extends BasePost> extends Abstrac
public POST getByUrl(String url) {
Assert.hasText(url, "Url must not be blank");
return basePostRepository.getByUrl(url).orElseThrow(() -> new NotFoundException("The post does not exist").setErrorData(url));
return basePostRepository.getByUrl(url).orElseThrow(() -> new NotFoundException("该文章不存在").setErrorData(url));
}
@Override
@ -87,7 +87,7 @@ public abstract class BasePostServiceImpl<POST extends BasePost> extends Abstrac
Optional<POST> postOptional = basePostRepository.getByUrlAndStatus(url, status);
return postOptional.orElseThrow(() -> new NotFoundException("The post with status " + status + " and url " + url + "was not existed").setErrorData(url));
return postOptional.orElseThrow(() -> new NotFoundException("The post with status " + status + " and url " + url + " was not existed").setErrorData(url));
}
@Override

View File

@ -152,7 +152,7 @@ public class CategoryServiceImpl extends AbstractCrudService<Category, Integer>
*/
@Override
public Category getBySlugName(String slugName) {
return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("The Category does not exist").setErrorData(slugName));
return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该分类已存在").setErrorData(slugName));
}
@Override

View File

@ -57,7 +57,7 @@ public class TagServiceImpl extends AbstractCrudService<Tag, Integer> implements
*/
@Override
public Tag getBySlugNameOfNonNull(String slugName) {
return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("The tag does not exist").setErrorData(slugName));
return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该标签已存在").setErrorData(slugName));
}

View File

@ -223,7 +223,7 @@ public class ThemeServiceImpl implements ThemeService {
try {
return new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ServiceException("Failed to read file " + absolutePath, e);
throw new ServiceException("读取模板内容失败 " + absolutePath, e);
}
}
@ -237,7 +237,7 @@ public class ThemeServiceImpl implements ThemeService {
try {
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
throw new ServiceException("Failed to write file " + absolutePath, e);
throw new ServiceException("保存模板内容失败 " + absolutePath, e);
}
}
@ -418,7 +418,7 @@ public class ThemeServiceImpl implements ThemeService {
.anyMatch(themeProperty -> themeProperty.getId().equalsIgnoreCase(tmpThemeProperty.getId()));
if (isExist) {
throw new AlreadyExistsException("The theme with id " + tmpThemeProperty.getId() + " has already existed");
throw new AlreadyExistsException("当前安装的主题已存在");
}
// Copy the temporary path to current theme folder
@ -722,7 +722,7 @@ public class ThemeServiceImpl implements ThemeService {
*/
@NonNull
private Path getThemePropertyPath(@NonNull Path themePath) {
return getThemePropertyPathOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException(themePath + " dose not exist any theme property file").setErrorData(themePath));
return getThemePropertyPathOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException(themePath + " 没有说明文件").setErrorData(themePath));
}
private Optional<ThemeProperty> getPropertyOfNullable(Path themePath) {
@ -773,7 +773,7 @@ public class ThemeServiceImpl implements ThemeService {
*/
@NonNull
private ThemeProperty getProperty(@NonNull Path themePath) {
return getPropertyOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException("Cannot resolve theme property").setErrorData(themePath));
return getPropertyOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException("该主题没有说明文件").setErrorData(themePath));
}
/**