mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
Distinguish between errors with and without details
This commit is contained in:
@@ -37,7 +37,8 @@ import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
|||||||
|
|
||||||
public class IntegrateChangesFromWorkdirException extends ExceptionWithContext {
|
public class IntegrateChangesFromWorkdirException extends ExceptionWithContext {
|
||||||
|
|
||||||
private static final String CODE = "CHRM7IQzo1";
|
static final String CODE_WITH_ADDITIONAL_MESSAGES = "CHRM7IQzo1";
|
||||||
|
static final String CODE_WITHOUT_ADDITIONAL_MESSAGES = "ASSG1ehZ01";
|
||||||
|
|
||||||
private static final Pattern SCM_MESSAGE_PATTERN = Pattern.compile(".*\\[SCM\\] (.*)");
|
private static final Pattern SCM_MESSAGE_PATTERN = Pattern.compile(".*\\[SCM\\] (.*)");
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class IntegrateChangesFromWorkdirException extends ExceptionWithContext {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return CODE;
|
return getAdditionalMessages().isEmpty()? CODE_WITHOUT_ADDITIONAL_MESSAGES : CODE_WITH_ADDITIONAL_MESSAGES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MessageExtractor {
|
public static class MessageExtractor {
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ import sonia.scm.repository.Repository;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.CODE_WITHOUT_ADDITIONAL_MESSAGES;
|
||||||
|
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.CODE_WITH_ADDITIONAL_MESSAGES;
|
||||||
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.forMessage;
|
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.forMessage;
|
||||||
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.withPattern;
|
import static sonia.scm.repository.spi.IntegrateChangesFromWorkdirException.withPattern;
|
||||||
|
|
||||||
@@ -39,11 +41,13 @@ class IntegrateChangesFromWorkdirExceptionTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void shouldExtractMessagesWithDefaultPrefix() {
|
void shouldExtractMessagesWithDefaultPrefix() {
|
||||||
IntegrateChangesFromWorkdirException exception = forMessage(REPOSITORY, "prefix [SCM] line 1\nprefix [SCM] line 2\nirrelevant line\n");
|
IntegrateChangesFromWorkdirException exception =
|
||||||
|
forMessage(REPOSITORY, "prefix [SCM] line 1\nprefix [SCM] line 2\nirrelevant line\n");
|
||||||
|
|
||||||
assertThat(exception.getAdditionalMessages())
|
assertThat(exception.getAdditionalMessages())
|
||||||
.extracting("message")
|
.extracting("message")
|
||||||
.containsExactly("line 1", "line 2");
|
.containsExactly("line 1", "line 2");
|
||||||
|
assertThat(exception.getCode()).isEqualTo(CODE_WITH_ADDITIONAL_MESSAGES);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -55,5 +59,15 @@ class IntegrateChangesFromWorkdirExceptionTest {
|
|||||||
assertThat(exception.getAdditionalMessages())
|
assertThat(exception.getAdditionalMessages())
|
||||||
.extracting("message")
|
.extracting("message")
|
||||||
.containsExactly("line");
|
.containsExactly("line");
|
||||||
|
assertThat(exception.getCode()).isEqualTo(CODE_WITH_ADDITIONAL_MESSAGES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldCreateSpecialMessageForMissingAdditionalMessages() {
|
||||||
|
IntegrateChangesFromWorkdirException exception =
|
||||||
|
forMessage(REPOSITORY, "There is no message");
|
||||||
|
|
||||||
|
assertThat(exception.getAdditionalMessages()).isEmpty();
|
||||||
|
assertThat(exception.getCode()).isEqualTo(CODE_WITHOUT_ADDITIONAL_MESSAGES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,17 @@ class BackendErrorNotification extends React.Component<Props> {
|
|||||||
renderAdditionalMessages = () => {
|
renderAdditionalMessages = () => {
|
||||||
const { error, t } = this.props;
|
const { error, t } = this.props;
|
||||||
if (error.additionalMessages) {
|
if (error.additionalMessages) {
|
||||||
return error.additionalMessages.map(a => a.key ? t(`errors.${a.key}.description`) : a.message).map(m => <p>{m}</p>);
|
return (
|
||||||
|
<>
|
||||||
|
<hr />
|
||||||
|
{error.additionalMessages
|
||||||
|
.map(a => (a.key ? t(`errors.${a.key}.description`) : a.message))
|
||||||
|
.map(m => (
|
||||||
|
<p>{m}</p>
|
||||||
|
))}
|
||||||
|
<hr />
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -197,7 +197,11 @@
|
|||||||
},
|
},
|
||||||
"CHRM7IQzo1": {
|
"CHRM7IQzo1": {
|
||||||
"displayName": "Änderung des Repositories nicht möglich",
|
"displayName": "Änderung des Repositories nicht möglich",
|
||||||
"description": "Die gewünschte Änderung am Repository konnte nicht durchgeführt werden. Höchst wahrscheinlich liegt dieses an installierten Plugins mit Hooks oder nativen Hooks. Folgend sind eventuelle weitere Meldungen."
|
"description": "Die gewünschte Änderung am Repository konnte nicht durchgeführt werden. Höchst wahrscheinlich liegt dieses an Prüfungen von Plugins. Bitte prüfen Sie die Einstellungen. Im Folgenden finden Sie weitere Meldungen zu dem Fehler:"
|
||||||
|
},
|
||||||
|
"ASSG1ehZ01": {
|
||||||
|
"displayName": "Änderung des Repositories nicht möglich",
|
||||||
|
"description": "Die gewünschte Änderung am Repository konnte nicht durchgeführt werden. Es gab keine weiteren Meldungen."
|
||||||
},
|
},
|
||||||
"thbsUFokjk": {
|
"thbsUFokjk": {
|
||||||
"displayName": "Unerlaubte Änderung eines Schlüsselwerts",
|
"displayName": "Unerlaubte Änderung eines Schlüsselwerts",
|
||||||
|
|||||||
@@ -197,7 +197,11 @@
|
|||||||
},
|
},
|
||||||
"CHRM7IQzo1": {
|
"CHRM7IQzo1": {
|
||||||
"displayName": "Could not modify repository",
|
"displayName": "Could not modify repository",
|
||||||
"description": "The requested modification to the repository was rejected. Most probably this was due to plugins with repository hooks or native hooks. Following are potential additional messages."
|
"description": "The requested modification to the repository was rejected. The most likely reason for this are checks from plugins. Please check your settings. See the following messages for more details:"
|
||||||
|
},
|
||||||
|
"ASSG1ehZ01": {
|
||||||
|
"displayName": "Could not modify repository",
|
||||||
|
"description": "The requested modification to the repository was rejected. There were no more messages."
|
||||||
},
|
},
|
||||||
"thbsUFokjk": {
|
"thbsUFokjk": {
|
||||||
"displayName": "Illegal change of an identifier",
|
"displayName": "Illegal change of an identifier",
|
||||||
@@ -205,7 +209,7 @@
|
|||||||
},
|
},
|
||||||
"40RaYIeeR1": {
|
"40RaYIeeR1": {
|
||||||
"displayName": "No changes were made",
|
"displayName": "No changes were made",
|
||||||
"description": "No changes were made to the files of the repository. Therefor no new commit could be created. Possibly changes cannot be applied due to an .ignore-File definition."
|
"description": "No changes were made to the files of the repository. Therefore no new commit could be created. Possibly changes cannot be applied due to an .ignore-File definition."
|
||||||
},
|
},
|
||||||
"ERS2vYb7U1": {
|
"ERS2vYb7U1": {
|
||||||
"displayName": "Illegal change of namespace",
|
"displayName": "Illegal change of namespace",
|
||||||
@@ -213,7 +217,7 @@
|
|||||||
},
|
},
|
||||||
"4iRct4avG1": {
|
"4iRct4avG1": {
|
||||||
"displayName": "The revisions have unrelated histories",
|
"displayName": "The revisions have unrelated histories",
|
||||||
"description": "The revisions have unrelated histories. Therefor there is no common commit to compare with."
|
"description": "The revisions have unrelated histories. Therefore there is no common commit to compare with."
|
||||||
},
|
},
|
||||||
"65RdZ5atX1": {
|
"65RdZ5atX1": {
|
||||||
"displayName": "Error removing plugin files",
|
"displayName": "Error removing plugin files",
|
||||||
|
|||||||
Reference in New Issue
Block a user