Skip to content

Conversation

@k1278361885
Copy link
Contributor

public String getId() {
return super.getId();
return Optional.ofNullable(super.getId())
.orElseThrow(() -> new IllegalArgumentException("设备ID不能为空"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.使用ValidationException
2. 国际化

public String getId() {
return Optional.ofNullable(super.getId())
.orElseThrow(() -> new IllegalArgumentException("设备ID不能为空"));
.orElseThrow(() -> new ValidationException.NoStackTrace(LocaleUtils.resolveMessage("device.queryPropertyLatestCommand.param.error")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new ValidationException.NoStackTrace("id","validation.NotNull.deviceId")

public String getId() {
return super.getId();
return Optional.ofNullable(super.getId())
.orElseThrow(() -> new ValidationException.NoStackTrace("id", LocaleUtils.resolveMessage("validation.NotNull.deviceId")));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里不需要resolveMessage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants