• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torresj / community-api / 6

28 May 2025 02:43PM UTC coverage: 75.157% (+53.1%) from 22.105%
6

push

circleci

Jaime Torres Benavente
Security added

87 of 133 new or added lines in 15 files covered. (65.41%)

239 of 318 relevant lines covered (75.16%)

0.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.59
/src/main/java/com/torresj/community/exceptions/GlobalExceptionHandler.java
1
package com.torresj.community.exceptions;
2

3
import lombok.extern.slf4j.Slf4j;
4
import org.springframework.http.HttpStatus;
5
import org.springframework.http.ProblemDetail;
6
import org.springframework.web.bind.annotation.ControllerAdvice;
7
import org.springframework.web.bind.annotation.ExceptionHandler;
8
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
9

10
@ControllerAdvice
11
@Slf4j
1✔
12
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
1✔
13
    @ExceptionHandler(UserNotFoundException.class)
14
    ProblemDetail handleUserNotFound(UserNotFoundException e) {
15
        ProblemDetail problemDetail =
1✔
16
                ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, e.getMessage());
1✔
17
        problemDetail.setTitle(e.getMessage());
1✔
18
        log.error(e.toString());
1✔
19
        return problemDetail;
1✔
20
    }
21

22
    @ExceptionHandler(CommunityNotFoundException.class)
23
    ProblemDetail handleCommunityNotFoundException(CommunityNotFoundException e) {
24
        ProblemDetail problemDetail =
1✔
25
                ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, e.getMessage());
1✔
26
        problemDetail.setTitle(e.getMessage());
1✔
27
        log.error(e.toString());
1✔
28
        return problemDetail;
1✔
29
    }
30

31
    @ExceptionHandler(LoginException.class)
32
    ProblemDetail handleLoginException(LoginException e) {
NEW
33
        ProblemDetail problemDetail =
×
NEW
34
                ProblemDetail.forStatusAndDetail(HttpStatus.UNAUTHORIZED, e.getMessage());
×
NEW
35
        problemDetail.setTitle(e.getMessage());
×
NEW
36
        log.error(e.toString());
×
NEW
37
        return problemDetail;
×
38
    }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc