Improve error message.

main
Paulo Gustavo Veiga 2024-02-29 19:38:16 -08:00
parent d7ac0ec28f
commit 34acc83582
2 changed files with 13 additions and 16 deletions

View File

@ -30,7 +30,7 @@ public class AccessDeniedSecurityException
} }
public AccessDeniedSecurityException(@NotNull long mapId, Collaborator user) { public AccessDeniedSecurityException(@NotNull long mapId, Collaborator user) {
super("No enough permissions to access map. Id: " + mapId + ", User: " + user, Severity.FATAL); super("You do not have enough right access to see this map. This map has been changed to private or deleted.", Severity.FATAL);
} }
@NotNull @NotNull

View File

@ -30,9 +30,6 @@ import org.springframework.validation.Errors;
import org.springframework.validation.FieldError; import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError; import org.springframework.validation.ObjectError;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
import java.util.*; import java.util.*;
@JsonAutoDetect( @JsonAutoDetect(
@ -47,13 +44,13 @@ public class RestErrors {
private Errors errors; private Errors errors;
@JsonIgnore @JsonIgnore
private List<String> gErrors; private List<String> globalError;
@JsonIgnore @JsonIgnore
MessageSource messageSource; private MessageSource messageSource;
@JsonIgnore @JsonIgnore
Severity gSeverity; private Severity globalSeverity;
@Nullable @Nullable
@JsonIgnore @JsonIgnore
@ -67,8 +64,8 @@ public class RestErrors {
this.errors = errors; this.errors = errors;
this.messageSource = messageSource; this.messageSource = messageSource;
this.gErrors = this.processGlobalErrors(errors); this.globalError = this.processGlobalErrors(errors);
this.gSeverity = Severity.WARNING; this.globalSeverity = Severity.WARNING;
} }
public RestErrors(@NotNull String errorMsg, @NotNull Severity severity) { public RestErrors(@NotNull String errorMsg, @NotNull Severity severity) {
@ -78,9 +75,9 @@ public class RestErrors {
public RestErrors(@NotNull String errorMsg, @NotNull Severity severity, @Nullable String debugInfo) { public RestErrors(@NotNull String errorMsg, @NotNull Severity severity, @Nullable String debugInfo) {
this._debugInfo = debugInfo; this._debugInfo = debugInfo;
this.gErrors = new ArrayList<>(); this.globalError = new ArrayList<>();
this.gErrors.add(errorMsg); this.globalError.add(errorMsg);
this.gSeverity = severity; this.globalSeverity = severity;
} }
private List<String> processGlobalErrors(@NotNull Errors errors) { private List<String> processGlobalErrors(@NotNull Errors errors) {
@ -123,7 +120,7 @@ public class RestErrors {
@Nullable @Nullable
public String getGlobalSeverity() { public String getGlobalSeverity() {
return this.gSeverity.toString(); return this.globalSeverity.toString();
} }
@Nullable @Nullable
@ -132,16 +129,16 @@ public class RestErrors {
} }
public List<String> getGlobalErrors() { public List<String> getGlobalErrors() {
return gErrors; return globalError;
} }
@Override @Override
public String toString() { public String toString() {
return "RestErrors{" + return "RestErrors{" +
"errors=" + errors + "errors=" + errors +
", gErrors=" + gErrors + ", gErrors=" + globalError +
", messageSource=" + messageSource + ", messageSource=" + messageSource +
", gSeverity=" + gSeverity + ", gSeverity=" + globalSeverity +
", _debugInfo='" + _debugInfo + '\'' + ", _debugInfo='" + _debugInfo + '\'' +
'}'; '}';
} }