Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_weekendowa_20221008
Commits
c2da37f9
Commit
c2da37f9
authored
Nov 26, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ExceptionUtils i wypisywanie wszystkich błędów
parent
0f9ff0c1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
2 deletions
+24
-2
ProductController.java
...ing/src/main/java/sklep/controller/ProductController.java
+2
-1
ExceptionUtils.java
...SklepSpring/src/main/java/sklep/utils/ExceptionUtils.java
+22
-0
styl.css
PC30-SklepSpring/src/main/webapp/styl.css
+0
-1
No files found.
PC30-SklepSpring/src/main/java/sklep/controller/ProductController.java
View file @
c2da37f9
...
...
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
sklep.model.Product
;
import
sklep.repository.ProductRepository
;
import
sklep.utils.ExceptionUtils
;
@Controller
@RequestMapping
(
"/products"
)
...
...
@@ -94,7 +95,7 @@ public class ProductController {
productRepository
.
save
(
product
);
model
.
addAttribute
(
"saved"
,
true
);
}
catch
(
Exception
e
)
{
model
.
addAttribute
(
"errors"
,
List
.
of
(
e
.
toString
()
));
model
.
addAttribute
(
"errors"
,
ExceptionUtils
.
allMessages
(
e
));
}
return
"product_form"
;
}
...
...
PC30-SklepSpring/src/main/java/sklep/utils/ExceptionUtils.java
0 → 100644
View file @
c2da37f9
package
sklep
.
utils
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
ExceptionUtils
{
public
static
List
<
String
>
allMessages
(
Throwable
e
)
{
List
<
String
>
messages
=
new
ArrayList
<>();
messages
.
add
(
oneMessage
(
e
));
Throwable
cause
=
e
.
getCause
();
while
(
cause
!=
null
)
{
messages
.
add
(
oneMessage
(
cause
));
cause
=
cause
.
getCause
();
}
return
messages
;
}
private
static
String
oneMessage
(
Throwable
e
)
{
return
e
.
getClass
().
getSimpleName
()
+
": "
+
e
.
getMessage
();
}
}
PC30-SklepSpring/src/main/webapp/styl.css
View file @
c2da37f9
...
...
@@ -60,7 +60,6 @@ h2, h3, h4 {
background-color
:
white
;
font-weight
:
bold
;
min-width
:
500px
;
max-width
:
1000px
;
}
#wyszukiwarka
{
...
...
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