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

uber / h3-java / #405

11 Aug 2024 08:49PM CUT coverage: 98.805%. Remained the same
#405

push

github

web-flow
update pom.xml to a valid email address (#145)

496 of 502 relevant lines covered (98.8%)

0.99 hits per line

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

100.0
/src/main/java/com/uber/h3core/exceptions/H3Exception.java
1
/*
2
 * Copyright 2022 Uber Technologies, Inc.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *         http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package com.uber.h3core.exceptions;
17

18
/**
19
 * An exception from the H3 core library.
20
 *
21
 * <p>The error code contained in an H3Exception comes from the H3 core library. The H3
22
 * documentation contains a <a
23
 * href="https://h3geo.org/docs/library/errors/#table-of-error-codes">table of error codes</a>.
24
 */
25
public class H3Exception extends RuntimeException {
26
  private int code;
27

28
  public H3Exception(int code) {
29
    super(codeToMessage(code));
1✔
30
    this.code = code;
1✔
31
  }
1✔
32

33
  public int getCode() {
34
    return code;
1✔
35
  }
36

37
  public static String codeToMessage(int code) {
38
    switch (code) {
1✔
39
      case 0:
40
        return "Success";
1✔
41
      case 1:
42
        return "The operation failed but a more specific error is not available";
1✔
43
      case 2:
44
        return "Argument was outside of acceptable range";
1✔
45
      case 3:
46
        return "Latitude or longitude arguments were outside of acceptable range";
1✔
47
      case 4:
48
        return "Resolution argument was outside of acceptable range";
1✔
49
      case 5:
50
        return "Cell argument was not valid";
1✔
51
      case 6:
52
        return "Directed edge argument was not valid";
1✔
53
      case 7:
54
        return "Undirected edge argument was not valid";
1✔
55
      case 8:
56
        return "Vertex argument was not valid";
1✔
57
      case 9:
58
        return "Pentagon distortion was encountered";
1✔
59
      case 10:
60
        return "Duplicate input";
1✔
61
      case 11:
62
        return "Cell arguments were not neighbors";
1✔
63
      case 12:
64
        return "Cell arguments had incompatible resolutions";
1✔
65
      case 13:
66
        return "Memory allocation failed";
1✔
67
      case 14:
68
        return "Bounds of provided memory were insufficient";
1✔
69
      case 15:
70
        return "Mode or flags argument was not valid";
1✔
71
      default:
72
        return "Unknown error";
1✔
73
    }
74
  }
75
}
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