Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
echo "${{ secrets.TEST_PROPERTIES }}" | base64 --decode > src/test/resources/application.yml
mkdir -p src/main/resources/credential
echo "${{ secrets.FCM_KEY }}" | base64 --decode > src/main/resources/credential/fcm-service-key.json
echo "${{ secrets.GRADLE }}" | base64 --decode > ./gradle.properties

- name: Grant execute permission for gradlew
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
echo "${{ secrets.TEST_PROPERTIES }}" | base64 --decode > src/test/resources/application.yml
mkdir -p src/main/resources/credential
echo "${{ secrets.FCM_KEY }}" | base64 --decode > src/main/resources/credential/fcm-service-key.json
echo "${{ secrets.GRADLE }}" | base64 --decode > ./gradle.properties


- name: Grant execute permission for gradlew
Expand Down
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id "io.sentry.jvm.gradle" version "4.4.1"
}

group = 'com.yanolja'
Expand All @@ -12,6 +13,9 @@ java {
sourceCompatibility = '17'
}

generateSentryBundleIdJava.dependsOn compileJava
sentryCollectSourcesJava.dependsOn compileTestJava

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand All @@ -23,6 +27,17 @@ repositories {
mavenCentral()
}

sentry {
// Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry.
// This enables source context, allowing you to see your source
// code as part of your stack traces in Sentry.
includeSourceContext = true

org = "eb256c3f1cf9"
projectName = "java-spring-boot"
authToken = System.getenv("SENTRY_AUTH_TOKEN")
}

ext {
set('snippetsDir', file("build/generated-snippets"))
}
Expand Down Expand Up @@ -102,6 +117,8 @@ dependencies {
// restdocs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'

implementation 'io.sentry:sentry-spring-boot-starter-jakarta:7.8.0'
}

def querydslDir = "src/main/generated"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.jsonwebtoken.MalformedJwtException;
import io.jsonwebtoken.UnsupportedJwtException;
import io.jsonwebtoken.security.SignatureException;
import io.sentry.Sentry;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindException;
Expand All @@ -17,32 +18,37 @@ public class GlobalRestControllerAdvice {

@ExceptionHandler
public ResponseEntity<ResponseDTO<String>> bindException(BindException e) {
Sentry.captureException(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 에러로그볼려구 했구낭 굿굿! 나중에 알려줘

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

예스~~

return ResponseEntity.status(HttpStatus.BAD_REQUEST)
.body(ResponseDTO.res(e.getBindingResult().getAllErrors().get(0).getDefaultMessage()));
}

@ExceptionHandler
public ResponseEntity<ResponseDTO<String>> applicationException(ApplicationException e) {
Sentry.captureException(e);
return ResponseEntity.status(e.getErrorCode().getHttpStatus())
.body(ResponseDTO.res(e.getMessage()));

}

@ExceptionHandler
public ResponseEntity<ResponseDTO<String>> expiredJWTException(ExpiredJwtException e) {
Sentry.captureException(e);
return ResponseEntity.status(ErrorCode.EXPIRED_TOKEN.getHttpStatus())
.body(ResponseDTO.res(ErrorCode.EXPIRED_TOKEN.getSimpleMessage()));
}

@ExceptionHandler({MalformedJwtException.class, SignatureException.class,
UnsupportedJwtException.class})
public ResponseEntity<ResponseDTO<String>> invalidJWTException(Exception e) {
Sentry.captureException(e);
return ResponseEntity.status(ErrorCode.INVALID_TOKEN.getHttpStatus())
.body(ResponseDTO.res(ErrorCode.INVALID_TOKEN.getSimpleMessage()));
}

@ExceptionHandler
public ResponseEntity<ResponseDTO<String>> ValidationException(MethodValidationException e) {
Sentry.captureException(e);
return ResponseEntity.badRequest().body(ResponseDTO.res(e.getMessage()));
}
}