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

leeonky / test-charm-java / 218

15 Apr 2025 02:45PM UTC coverage: 74.045% (-0.04%) from 74.088%
218

push

circleci

leeonky
Introduce adaptiveList

20 of 21 new or added lines in 3 files covered. (95.24%)

34 existing lines in 11 files now uncovered.

7968 of 10761 relevant lines covered (74.05%)

0.74 hits per line

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

81.58
/DAL-java/src/main/java/com/github/leeonky/dal/runtime/DalException.java
1
package com.github.leeonky.dal.runtime;
2

3
import com.github.leeonky.interpreter.InterpreterException;
4

5
import java.util.Optional;
6

7
public class DalException extends InterpreterException {
8
    private final Throwable cause;
9

10
    public DalException(String message, int position) {
11
        this(message, position, Position.Type.CHAR, null);
1✔
12
    }
1✔
13

14
    public DalException(String message, int position, Throwable cause) {
UNCOV
15
        this(message, position, Position.Type.CHAR, cause);
×
16
    }
×
17

18
    public DalException(String message, int position, Position.Type type) {
UNCOV
19
        this(message, position, type, null);
×
20
    }
×
21

22
    public DalException(String message, int position, Position.Type type, Throwable cause) {
23
        super(message, position, type);
1✔
24
        this.cause = cause;
1✔
25
    }
1✔
26

27
    public DalException(int position, Throwable cause) {
28
        this(null, position, Position.Type.CHAR, cause);
1✔
29
    }
1✔
30

31
    public DalException(int position, Position.Type type, Throwable cause) {
UNCOV
32
        this(null, position, type, cause);
×
33
    }
×
34

35
    public static Optional<Throwable> extractException(Throwable e) {
36
        if (e instanceof UserRuntimeException)
1✔
37
            return Optional.ofNullable(e.getCause());
1✔
38
        if (e.getCause() == null)
1✔
39
            return Optional.empty();
1✔
40
        return extractException(e.getCause());
1✔
41
    }
42

43
    @Override
44
    public Throwable getCause() {
45
        return cause;
1✔
46
    }
47

48
    @Override
49
    public String getMessage() {
50
        return buildMessage(this, super.getMessage());
1✔
51
    }
52

53
    @Override
54
    public String toString() {
UNCOV
55
        return getMessage();
×
56
    }
57

58
    public static String buildMessage(Throwable e, String message) {
59
        if (message != null && !message.isEmpty()) {
1✔
60
            Throwable cause = e.getCause();
1✔
61
            if (cause != null)
1✔
62
                return message + "\n" + cause;
1✔
63
            return message;
1✔
64
        }
65
        Throwable cause = e.getCause();
1✔
66
        if (cause != null)
1✔
67
            return cause.toString();
1✔
68
        return e.getClass().getName();
1✔
69
    }
70

71
    public static RuntimeException locateError(Throwable e, int positionBegin) {
72
        if (e instanceof InterpreterException || e instanceof ExpressionException)
1✔
73
            return (RuntimeException) e;
1✔
74
        if (e instanceof AssertionError)
1✔
75
            return new AssertionFailure(e.getMessage(), positionBegin);
1✔
76
        return new DalException(positionBegin, e);
1✔
77
    }
78

79
    public static Throwable buildUserRuntimeException(Throwable error) {
80
        if (error instanceof DalRuntimeException
1✔
81
                || error instanceof UserRuntimeException
82
                || error instanceof AssertionError
83
                || error instanceof ExpressionException
84
                || error instanceof InterpreterException)
85
            return error;
1✔
86
        return new UserRuntimeException(error);
1✔
87
    }
88
}
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