Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
flight-agency-app
Project
Project
Details
Activity
Releases
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
Heber Cordova
flight-agency-app
Commits
60732c3c
Commit
60732c3c
authored
Oct 26, 2023
by
Heber Cordova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: added exception handler
parent
a0dd0f9b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
0 deletions
+92
-0
dockerfile
flight-agency-api/dockerfile
+9
-0
ExceptionController.java
...va/flightagencyapi/shared/config/ExceptionController.java
+19
-0
ErrorMessage.java
...com/hcordova/flightagencyapi/shared/dto/ErrorMessage.java
+16
-0
NotFoundException.java
.../flightagencyapi/shared/exceptions/NotFoundException.java
+19
-0
additional-spring-configuration-metadata.json
...es/META-INF/additional-spring-configuration-metadata.json
+12
-0
application.properties
flight-agency-api/src/main/resources/application.properties
+17
-0
No files found.
flight-agency-api/dockerfile
0 → 100644
View file @
60732c3c
FROM
openjdk:latest
WORKDIR
/app
COPY
target/*.jar app.jar
EXPOSE
8080
ENTRYPOINT
["java","-jar","app.jar"]
\ No newline at end of file
flight-agency-api/src/main/java/com/hcordova/flightagencyapi/shared/config/ExceptionController.java
0 → 100644
View file @
60732c3c
package
com
.
hcordova
.
flightagencyapi
.
shared
.
config
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
com.hcordova.flightagencyapi.shared.dto.ErrorMessage
;
import
com.hcordova.flightagencyapi.shared.exceptions.NotFoundException
;
@ControllerAdvice
public
class
ExceptionController
{
@ExceptionHandler
(
NotFoundException
.
class
)
public
ResponseEntity
<
ErrorMessage
>
notFoundException
(
NotFoundException
ex
)
{
ErrorMessage
errorMessage
=
new
ErrorMessage
(
ex
.
getMessage
(),
HttpStatus
.
NOT_FOUND
,
ex
.
getPath
());
return
new
ResponseEntity
<>(
errorMessage
,
HttpStatus
.
NOT_FOUND
);
}
}
flight-agency-api/src/main/java/com/hcordova/flightagencyapi/shared/dto/ErrorMessage.java
0 → 100644
View file @
60732c3c
package
com
.
hcordova
.
flightagencyapi
.
shared
.
dto
;
import
org.springframework.http.HttpStatus
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.Setter
;
@AllArgsConstructor
@Getter
@Setter
public
class
ErrorMessage
{
private
String
message
;
private
HttpStatus
code
;
private
String
path
;
}
flight-agency-api/src/main/java/com/hcordova/flightagencyapi/shared/exceptions/NotFoundException.java
0 → 100644
View file @
60732c3c
package
com
.
hcordova
.
flightagencyapi
.
shared
.
exceptions
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
@ResponseStatus
(
HttpStatus
.
NOT_FOUND
)
public
class
NotFoundException
extends
RuntimeException
{
private
String
path
;
public
NotFoundException
(
String
message
)
{
super
(
message
);
this
.
path
=
this
.
getLocalizedMessage
();
}
public
String
getPath
()
{
return
path
;
}
}
flight-agency-api/src/main/resources/META-INF/additional-spring-configuration-metadata.json
0 → 100644
View file @
60732c3c
{
"properties"
:
[
{
"name"
:
"db.host"
,
"type"
:
"java.lang.String"
,
"description"
:
"A description for 'db.host'"
},
{
"name"
:
"app.port"
,
"type"
:
"java.lang.String"
,
"description"
:
"A description for 'app.port'"
}
]}
\ No newline at end of file
flight-agency-api/src/main/resources/application.properties
View file @
60732c3c
# METADATA
db.host
=
my-flight-app-network
app.port
=
8080
# SERVER
server.port
=
${app.port}:8085}
# MYSQL
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
spring.datasource.url
=
jdbc:mysql://${db.host}:localhost}:3306/flightdatabase?useSSL=false&createDatabaseIfNotExists=true
spring.datasource.username
=
root
spring.datasource.password
=
admin
# JPA
spring.jpa.hibernate.ddl-auto
=
update
spring.jpa.database-platform
=
org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.dialect
=
org.hibernate.dialect.MySQL8Dialect
spring.jpa.show-sql
=
true
\ No newline at end of file
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