Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Aura Development Team
AuraSudo
Commits
2868e809
Verified
Commit
2868e809
authored
Jan 23, 2021
by
Yannick Schinko
Browse files
Fixes in the Exception base class
And even better exception logging
parent
21a08e6a
Pipeline
#393
passed with stages
in 4 minutes and 19 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
platform/common/src/main/java/team/aura_dev/aurasudo/platform/common/command/BaseCommand.java
View file @
2868e809
...
@@ -6,10 +6,14 @@ import java.util.Collection;
...
@@ -6,10 +6,14 @@ import java.util.Collection;
import
java.util.LinkedHashSet
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.List
;
import
lombok.Getter
;
import
lombok.Getter
;
import
org.slf4j.Logger
;
import
team.aura_dev.aurasudo.platform.common.AuraSudoBase
;
import
team.aura_dev.aurasudo.platform.common.permission.Permission
;
import
team.aura_dev.aurasudo.platform.common.permission.Permission
;
import
team.aura_dev.aurasudo.platform.common.player.PlayerDataCommon
;
import
team.aura_dev.aurasudo.platform.common.player.PlayerDataCommon
;
public
abstract
class
BaseCommand
{
public
abstract
class
BaseCommand
{
protected
static
final
Logger
logger
=
AuraSudoBase
.
logger
;
public
final
Permission
BASE
;
public
final
Permission
BASE
;
public
final
Permission
COMMAND
;
public
final
Permission
COMMAND
;
...
@@ -60,6 +64,14 @@ public abstract class BaseCommand {
...
@@ -60,6 +64,14 @@ public abstract class BaseCommand {
execute
(
player
,
alias
,
argumentList
);
execute
(
player
,
alias
,
argumentList
);
}
catch
(
RuntimeException
e
)
{
}
catch
(
RuntimeException
e
)
{
logger
.
warn
(
"Unexpected Exception during command execution of /"
+
alias
+
" (/@id@:"
+
getBaseCommand
()
+
"):"
,
e
);
throw
new
CommandExecutionException
(
e
);
throw
new
CommandExecutionException
(
e
);
}
}
}
catch
(
CommandExecutionException
e
)
{
}
catch
(
CommandExecutionException
e
)
{
...
...
platform/common/src/main/java/team/aura_dev/aurasudo/platform/common/command/CommandExecutionException.java
View file @
2868e809
...
@@ -2,6 +2,9 @@ package team.aura_dev.aurasudo.platform.common.command;
...
@@ -2,6 +2,9 @@ package team.aura_dev.aurasudo.platform.common.command;
import
java.io.PrintWriter
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
import
java.io.StringWriter
;
import
java.util.Arrays
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
net.kyori.adventure.text.Component
;
import
net.kyori.adventure.text.Component
;
import
net.kyori.adventure.text.TextComponent
;
import
net.kyori.adventure.text.TextComponent
;
import
net.kyori.adventure.text.format.NamedTextColor
;
import
net.kyori.adventure.text.format.NamedTextColor
;
...
@@ -23,15 +26,16 @@ public class CommandExecutionException extends Exception {
...
@@ -23,15 +26,16 @@ public class CommandExecutionException extends Exception {
super
(
message
,
cause
);
super
(
message
,
cause
);
this
.
message
=
this
.
message
=
Component
.
text
(
message
,
NamedTextColor
.
DARK_RED
)
Component
.
empty
()
.
append
(
Component
.
text
(
message
,
NamedTextColor
.
DARK_RED
))
.
append
(
Component
.
newline
())
.
append
(
Component
.
newline
())
.
append
(
.
append
(
Component
.
text
(
cause
.
getMessage
())
Component
.
text
(
cause
.
getClass
().
getName
()
+
": "
+
cause
.
getMessage
())
.
hoverEvent
(
Component
.
text
(
getStackTrace
(
cause
)).
asHoverEvent
()));
.
hoverEvent
(
Component
.
text
(
getStackTrace
(
cause
)).
asHoverEvent
()));
}
}
public
CommandExecutionException
(
Throwable
cause
)
{
public
CommandExecutionException
(
Throwable
cause
)
{
this
(
"Un
known error
"
,
cause
);
this
(
"Un
expected Exception:
"
,
cause
);
}
}
public
TextComponent
getMessageComponent
()
{
public
TextComponent
getMessageComponent
()
{
...
@@ -43,6 +47,14 @@ public class CommandExecutionException extends Exception {
...
@@ -43,6 +47,14 @@ public class CommandExecutionException extends Exception {
PrintWriter
pw
=
new
PrintWriter
(
sw
);
PrintWriter
pw
=
new
PrintWriter
(
sw
);
cause
.
printStackTrace
(
pw
);
cause
.
printStackTrace
(
pw
);
return
pw
.
toString
();
String
[]
splitStackTrace
=
sw
.
toString
().
replace
(
"\t"
,
" "
).
trim
().
split
(
"\r\n|\r|\n"
,
21
);
Stream
<
String
>
output
=
Arrays
.
stream
(
splitStackTrace
);
if
(
splitStackTrace
.
length
==
21
)
{
// Too many lines. Cut them off. Max 20 lines in the final string
output
=
Stream
.
concat
(
output
.
limit
(
19
),
Stream
.
of
(
"..."
));
}
return
output
.
collect
(
Collectors
.
joining
(
"\n"
));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment