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

leeonky / test-charm-java / 156

20 Mar 2025 01:53PM UTC coverage: 74.243% (-0.2%) from 74.475%
156

push

circleci

leeonky
Refactor

14 of 15 new or added lines in 12 files covered. (93.33%)

126 existing lines in 29 files now uncovered.

7947 of 10704 relevant lines covered (74.24%)

0.74 hits per line

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

79.49
/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
import com.github.leeonky.util.Sneaky;
5

6
import java.util.Optional;
7

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

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

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

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

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

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

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

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

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

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

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

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

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

80
    public static Object throwUserRuntimeException(Throwable error) {
UNCOV
81
        return Sneaky.sneakyThrow(buildUserRuntimeException(error));
×
82
    }
83

84
    public static Throwable buildUserRuntimeException(Throwable error) {
85
        if (error instanceof DalRuntimeException
1✔
86
                || error instanceof UserRuntimeException
87
                || error instanceof AssertionError
88
                || error instanceof ExpressionException
89
                || error instanceof InterpreterException)
90
            return error;
1✔
91
        return new UserRuntimeException(error);
1✔
92
    }
93
}
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