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

Hyshmily / hotkey / 28026418224

23 Jun 2026 12:32PM UTC coverage: 92.562% (-0.6%) from 93.188%
28026418224

push

github

Hyshmily
Release 1.1.51

Signed-off-by: Hyshmily <cxm8607@outlook.com>

1176 of 1323 branches covered (88.89%)

Branch coverage included in aggregate %.

61 of 76 new or added lines in 6 files covered. (80.26%)

3 existing lines in 1 file now uncovered.

3366 of 3584 relevant lines covered (93.92%)

4.24 hits per line

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

62.5
/common/src/main/java/io/github/hyshmily/hotkey/exception/HotKeyModeException.java
1
/*
2
 * Copyright 2026 Hyshmily. All Rights Reserved.
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 io.github.hyshmily.hotkey.exception;
17

18
/**
19
 * Thrown when a {@link io.github.hyshmily.hotkey.HotKey} API is called in a
20
 * deployment mode that does not support it.
21
 *
22
 * <p>For example, calling {@code hotKey.get(key, reader)} in Worker-only mode
23
 * throws this exception because there is no app-side cache. Callers can probe
24
 * the current mode before calling cache-dependent APIs:
25
 * <pre>{@code
26
 * if (hotKey.isApp()) {
27
 *     Optional<User> user = hotKey.get("user:42", repo::findById);
28
 * }
29
 * }</pre>
30
 *
31
 * <p>The exception carries three fields to help diagnose the mismatch:
32
 * <ul>
33
 *   <li>{@link #getOperation()} — the API name that was called</li>
34
 *   <li>{@link #getCurrentMode()} — the human-readable label of the current
35
 *       deployment mode (e.g. {@code "Worker-only mode"})</li>
36
 *   <li>{@link #getRequiredMode()} — the human-readable label of the mode
37
 *       required to perform the operation (e.g. {@code "App-mode cache"})</li>
38
 * </ul>
39
 *
40
 * @see io.github.hyshmily.hotkey.HotKey#isApp()
41
 * @see io.github.hyshmily.hotkey.HotKey#isWorker()
42
 */
43
public class HotKeyModeException extends RuntimeException {
44

45
  /** The API operation name that triggered the exception. */
46
  private final String operation;
47
  /** Human-readable label of the current deployment mode. */
48
  private final String currentMode;
49
  /** Human-readable label of the mode required to perform the operation. */
50
  private final String requiredMode;
51

52
  /**
53
   * Creates a new {@code HotKeyModeException}.
54
   *
55
   * @param operation     the API operation name that was called (e.g. {@code "get"})
56
   * @param currentMode   human-readable label of the current deployment mode
57
   *                      (e.g. {@code "Worker-only mode"})
58
   * @param requiredMode  human-readable label of the mode required to perform
59
   *                      the operation (e.g. {@code "App-mode cache"})
60
   */
61
  public HotKeyModeException(String operation, String currentMode, String requiredMode) {
62
    super("HotKey '" + operation + "' requires " + requiredMode +
6✔
63
          ", but instance is in " + currentMode);
64
    this.operation = operation;
3✔
65
    this.currentMode = currentMode;
3✔
66
    this.requiredMode = requiredMode;
3✔
67
  }
1✔
68

69
  /**
70
   * Returns the API operation name that triggered the exception.
71
   * @return the operation name (never {@code null})
72
   */
73
  public String getOperation() {
NEW
74
    return operation;
×
75
  }
76

77
  /**
78
   * Returns the human-readable label of the current deployment mode.
79
   * @return the current mode label (never {@code null})
80
   */
81
  public String getCurrentMode() {
NEW
82
    return currentMode;
×
83
  }
84

85
  /**
86
   * Returns the human-readable label of the mode required to perform the operation.
87
   * @return the required mode label (never {@code null})
88
   */
89
  public String getRequiredMode() {
NEW
90
    return requiredMode;
×
91
  }
92
}
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