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

box / box-java-sdk / #5925

17 Dec 2025 05:03PM UTC coverage: 35.453% (-0.1%) from 35.558%
#5925

push

github

web-flow
fix: add taxonomy to Metadata Field (read) definition (box/box-openapi#572) (#1644)

Co-authored-by: box-sdk-build <box-sdk-build@box.com>

2 of 2 new or added lines in 1 file covered. (100.0%)

62 existing lines in 13 files now uncovered.

18901 of 53313 relevant lines covered (35.45%)

0.35 hits per line

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

64.29
/src/main/java/com/box/sdkgen/box/errors/BoxAPIError.java
1
package com.box.sdkgen.box.errors;
2

3
import com.box.sdkgen.internal.logging.DataSanitizer;
4
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
5
import com.fasterxml.jackson.databind.JsonNode;
6
import java.time.LocalDateTime;
7
import java.util.Optional;
8
import okhttp3.Request;
9

10
public class BoxAPIError extends BoxSDKError {
11

12
  public final RequestInfo requestInfo;
13

14
  public final ResponseInfo responseInfo;
15

16
  private final DataSanitizer dataSanitizer;
17

18
  public BoxAPIError(String message, RequestInfo requestInfo, ResponseInfo responseInfo) {
19
    super(message);
×
20
    this.requestInfo = requestInfo;
×
21
    this.responseInfo = responseInfo;
×
22
    this.dataSanitizer = new DataSanitizer();
×
23
  }
×
24

25
  public static BoxAPIError fromAPICall(
26
      Request request,
27
      FetchResponse fetchResponse,
28
      String rawResponseBody,
29
      DataSanitizer dataSanitizer) {
30
    RequestInfo requestInfo = RequestInfo.fromRequest(request);
1✔
31
    ResponseInfo responseInfo = ResponseInfo.fromResponse(fetchResponse, rawResponseBody);
1✔
32

33
    String requestId =
1✔
34
        Optional.ofNullable(responseInfo.getBody())
1✔
35
            .map(body -> body.get("request_id"))
1✔
36
            .map(JsonNode::asText)
1✔
37
            .orElse("");
1✔
38

39
    return new Builder(
1✔
40
            String.format("Status %d; Request ID: %s", responseInfo.getStatusCode(), requestId),
1✔
41
            requestInfo,
42
            responseInfo)
43
        .timestamp(LocalDateTime.now().toString())
1✔
44
        .dataSanitizer(dataSanitizer)
1✔
45
        .build();
1✔
46
  }
47

48
  protected BoxAPIError(Builder builder) {
49
    super(builder);
1✔
50
    this.requestInfo = builder.requestInfo;
1✔
51
    this.responseInfo = builder.responseInfo;
1✔
52
    this.dataSanitizer = builder.dataSanitizer;
1✔
53
  }
1✔
54

55
  public RequestInfo getRequestInfo() {
56
    return requestInfo;
×
57
  }
58

59
  public ResponseInfo getResponseInfo() {
60
    return responseInfo;
×
61
  }
62

63
  public static class Builder extends BoxSDKError.Builder {
64

65
    protected final RequestInfo requestInfo;
66

67
    protected final ResponseInfo responseInfo;
68

69
    protected DataSanitizer dataSanitizer;
70

71
    public Builder(String message, RequestInfo requestInfo, ResponseInfo responseInfo) {
72
      super(message);
1✔
73
      this.requestInfo = requestInfo;
1✔
74
      this.responseInfo = responseInfo;
1✔
75
      this.dataSanitizer = new DataSanitizer();
1✔
76
    }
1✔
77

78
    @Override
79
    public Builder timestamp(String timestamp) {
80
      this.timestamp = timestamp;
1✔
81
      return this;
1✔
82
    }
83

84
    @Override
85
    public Builder error(Exception error) {
86
      this.error = error;
×
87
      return this;
×
88
    }
89

90
    @Override
91
    public Builder name(String name) {
92
      this.name = name;
×
93
      return this;
×
94
    }
95

96
    public Builder dataSanitizer(DataSanitizer dataSanitizer) {
97
      this.dataSanitizer = dataSanitizer;
1✔
98
      return this;
1✔
99
    }
100

101
    public BoxAPIError build() {
102
      return new BoxAPIError(this);
1✔
103
    }
104
  }
105

106
  @Override
107
  public String toString() {
UNCOV
108
    return String.join(
×
109
        "",
UNCOV
110
        super.toString(),
×
UNCOV
111
        String.format("\nRequest: %s", requestInfo.print(dataSanitizer)),
×
UNCOV
112
        String.format("\nResponse: %s", responseInfo.print(dataSanitizer)));
×
113
  }
114
}
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

© 2025 Coveralls, Inc