|
| 1 | +<!DOCTYPE HTML> |
| 2 | +<html lang> |
| 3 | +<head> |
| 4 | +<!-- Generated by javadoc (17) on Tue Apr 21 17:40:29 UTC 2026 --> |
| 5 | +<title>EventErrorHandler (GitHub Copilot SDK :: Java 0.3.0-java-preview.1 API)</title> |
| 6 | +<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 7 | +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| 8 | +<meta name="dc.created" content="2026-04-21"> |
| 9 | +<meta name="description" content="declaration: package: com.github.copilot.sdk, interface: EventErrorHandler"> |
| 10 | +<meta name="generator" content="javadoc/ClassWriterImpl"> |
| 11 | +<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style"> |
| 12 | +<link rel="stylesheet" type="text/css" href="../../../../script-dir/jquery-ui.min.css" title="Style"> |
| 13 | +<link rel="stylesheet" type="text/css" href="../../../../jquery-ui.overrides.css" title="Style"> |
| 14 | +<script type="text/javascript" src="../../../../script.js"></script> |
| 15 | +<script type="text/javascript" src="../../../../script-dir/jquery-3.7.1.min.js"></script> |
| 16 | +<script type="text/javascript" src="../../../../script-dir/jquery-ui.min.js"></script> |
| 17 | +</head> |
| 18 | +<body class="class-declaration-page"> |
| 19 | +<script type="text/javascript">var evenRowColor = "even-row-color"; |
| 20 | +var oddRowColor = "odd-row-color"; |
| 21 | +var tableTab = "table-tab"; |
| 22 | +var activeTableTab = "active-table-tab"; |
| 23 | +var pathtoroot = "../../../../"; |
| 24 | +loadScripts(document, 'script');</script> |
| 25 | +<noscript> |
| 26 | +<div>JavaScript is disabled on your browser.</div> |
| 27 | +</noscript> |
| 28 | +<div class="flex-box"> |
| 29 | +<header role="banner" class="flex-header"> |
| 30 | +<nav role="navigation"> |
| 31 | +<!-- ========= START OF TOP NAVBAR ======= --> |
| 32 | +<div class="top-nav" id="navbar-top"> |
| 33 | +<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| 34 | +<ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| 35 | +<li><a href="../../../../index.html">Overview</a></li> |
| 36 | +<li><a href="package-summary.html">Package</a></li> |
| 37 | +<li class="nav-bar-cell1-rev">Class</li> |
| 38 | +<li><a href="class-use/EventErrorHandler.html">Use</a></li> |
| 39 | +<li><a href="package-tree.html">Tree</a></li> |
| 40 | +<li><a href="../../../../deprecated-list.html">Deprecated</a></li> |
| 41 | +<li><a href="../../../../index-all.html">Index</a></li> |
| 42 | +</ul> |
| 43 | +</div> |
| 44 | +<div class="sub-nav"> |
| 45 | +<div> |
| 46 | +<ul class="sub-nav-list"> |
| 47 | +<li>Summary: </li> |
| 48 | +<li>Nested | </li> |
| 49 | +<li>Field | </li> |
| 50 | +<li>Constr | </li> |
| 51 | +<li><a href="#method-summary">Method</a></li> |
| 52 | +</ul> |
| 53 | +<ul class="sub-nav-list"> |
| 54 | +<li>Detail: </li> |
| 55 | +<li>Field | </li> |
| 56 | +<li>Constr | </li> |
| 57 | +<li><a href="#method-detail">Method</a></li> |
| 58 | +</ul> |
| 59 | +</div> |
| 60 | +<div class="nav-list-search"><label for="search-input">SEARCH:</label> |
| 61 | +<input type="text" id="search-input" value="search" disabled="disabled"> |
| 62 | +<input type="reset" id="reset-button" value="reset" disabled="disabled"> |
| 63 | +</div> |
| 64 | +</div> |
| 65 | +<!-- ========= END OF TOP NAVBAR ========= --> |
| 66 | +<span class="skip-nav" id="skip-navbar-top"></span></nav> |
| 67 | +</header> |
| 68 | +<div class="flex-content"> |
| 69 | +<main role="main"> |
| 70 | +<!-- ======== START OF CLASS DATA ======== --> |
| 71 | +<div class="header"> |
| 72 | +<div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">com.github.copilot.sdk</a></div> |
| 73 | +<h1 title="Interface EventErrorHandler" class="title">Interface EventErrorHandler</h1> |
| 74 | +</div> |
| 75 | +<section class="class-description" id="class-description"> |
| 76 | +<dl class="notes"> |
| 77 | +<dt>Functional Interface:</dt> |
| 78 | +<dd>This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.</dd> |
| 79 | +</dl> |
| 80 | +<hr> |
| 81 | +<div class="type-signature"><span class="annotations"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/FunctionalInterface.html" title="class or interface in java.lang" class="external-link">@FunctionalInterface</a> |
| 82 | +</span><span class="modifiers">public interface </span><span class="element-name type-name-label">EventErrorHandler</span></div> |
| 83 | +<div class="block">A handler for errors thrown by event handlers during event dispatch. |
| 84 | + <p> |
| 85 | + When an event handler registered via |
| 86 | + <a href="CopilotSession.html#on(java.util.function.Consumer)"><code>CopilotSession.on(java.util.function.Consumer)</code></a> or |
| 87 | + <a href="CopilotSession.html#on(java.lang.Class,java.util.function.Consumer)"><code>CopilotSession.on(Class, java.util.function.Consumer)</code></a> throws an |
| 88 | + exception, the <code>EventErrorHandler</code> is invoked with the event that was |
| 89 | + being dispatched and the exception that was thrown. |
| 90 | + |
| 91 | + <p> |
| 92 | + Errors are always logged at <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.logging/java/util/logging/Level.html#WARNING" title="class or interface in java.util.logging" class="external-link"><code>Level.WARNING</code></a> |
| 93 | + regardless of whether an error handler is set. The error handler provides |
| 94 | + additional custom handling such as metrics, alerts, or integration with |
| 95 | + external error-reporting systems: |
| 96 | + |
| 97 | + <pre><code> |
| 98 | + session.setEventErrorHandler((event, exception) -> { |
| 99 | + metrics.increment("handler.errors"); |
| 100 | + logger.error("Handler failed on {}: {}", event.getType(), exception.getMessage()); |
| 101 | + }); |
| 102 | + </code></pre> |
| 103 | + |
| 104 | + <p> |
| 105 | + Whether dispatch continues or stops after an error is controlled by the |
| 106 | + <a href="EventErrorPolicy.html" title="enum class in com.github.copilot.sdk"><code>EventErrorPolicy</code></a> set via |
| 107 | + <a href="CopilotSession.html#setEventErrorPolicy(com.github.copilot.sdk.EventErrorPolicy)"><code>CopilotSession.setEventErrorPolicy(EventErrorPolicy)</code></a>. The error |
| 108 | + handler is always invoked regardless of the policy. |
| 109 | + |
| 110 | + <p> |
| 111 | + If the error handler itself throws an exception, that exception is caught and |
| 112 | + logged at <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.logging/java/util/logging/Level.html#SEVERE" title="class or interface in java.util.logging" class="external-link"><code>Level.SEVERE</code></a>, and dispatch is stopped |
| 113 | + regardless of the configured policy.</div> |
| 114 | +<dl class="notes"> |
| 115 | +<dt>Since:</dt> |
| 116 | +<dd>1.0.8</dd> |
| 117 | +<dt>See Also:</dt> |
| 118 | +<dd> |
| 119 | +<ul class="see-list-long"> |
| 120 | +<li><a href="CopilotSession.html#setEventErrorHandler(com.github.copilot.sdk.EventErrorHandler)"><code>CopilotSession.setEventErrorHandler(EventErrorHandler)</code></a></li> |
| 121 | +<li><a href="EventErrorPolicy.html" title="enum class in com.github.copilot.sdk"><code>EventErrorPolicy</code></a></li> |
| 122 | +</ul> |
| 123 | +</dd> |
| 124 | +</dl> |
| 125 | +</section> |
| 126 | +<section class="summary"> |
| 127 | +<ul class="summary-list"> |
| 128 | +<!-- ========== METHOD SUMMARY =========== --> |
| 129 | +<li> |
| 130 | +<section class="method-summary" id="method-summary"> |
| 131 | +<h2>Method Summary</h2> |
| 132 | +<div id="method-summary-table"> |
| 133 | +<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button></div> |
| 134 | +<div id="method-summary-table.tabpanel" role="tabpanel" aria-labelledby="method-summary-table-tab0"> |
| 135 | +<div class="summary-table three-column-summary"> |
| 136 | +<div class="table-header col-first">Modifier and Type</div> |
| 137 | +<div class="table-header col-second">Method</div> |
| 138 | +<div class="table-header col-last">Description</div> |
| 139 | +<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>void</code></div> |
| 140 | +<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#handleError(com.github.copilot.sdk.generated.SessionEvent,java.lang.Exception)" class="member-name-link">handleError</a><wbr>(<a href="generated/SessionEvent.html" title="class in com.github.copilot.sdk.generated">SessionEvent</a> event, |
| 141 | + <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Exception.html" title="class or interface in java.lang" class="external-link">Exception</a> exception)</code></div> |
| 142 | +<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| 143 | +<div class="block">Called when an event handler throws an exception during event dispatch.</div> |
| 144 | +</div> |
| 145 | +</div> |
| 146 | +</div> |
| 147 | +</div> |
| 148 | +</section> |
| 149 | +</li> |
| 150 | +</ul> |
| 151 | +</section> |
| 152 | +<section class="details"> |
| 153 | +<ul class="details-list"> |
| 154 | +<!-- ============ METHOD DETAIL ========== --> |
| 155 | +<li> |
| 156 | +<section class="method-details" id="method-detail"> |
| 157 | +<h2>Method Details</h2> |
| 158 | +<ul class="member-list"> |
| 159 | +<li> |
| 160 | +<section class="detail" id="handleError(com.github.copilot.sdk.generated.SessionEvent,java.lang.Exception)"> |
| 161 | +<h3>handleError</h3> |
| 162 | +<div class="member-signature"><span class="return-type">void</span> <span class="element-name">handleError</span><wbr><span class="parameters">(<a href="generated/SessionEvent.html" title="class in com.github.copilot.sdk.generated">SessionEvent</a> event, |
| 163 | + <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Exception.html" title="class or interface in java.lang" class="external-link">Exception</a> exception)</span></div> |
| 164 | +<div class="block">Called when an event handler throws an exception during event dispatch.</div> |
| 165 | +<dl class="notes"> |
| 166 | +<dt>Parameters:</dt> |
| 167 | +<dd><code>event</code> - the event that was being dispatched when the error occurred</dd> |
| 168 | +<dd><code>exception</code> - the exception thrown by the event handler</dd> |
| 169 | +</dl> |
| 170 | +</section> |
| 171 | +</li> |
| 172 | +</ul> |
| 173 | +</section> |
| 174 | +</li> |
| 175 | +</ul> |
| 176 | +</section> |
| 177 | +<!-- ========= END OF CLASS DATA ========= --> |
| 178 | +</main> |
| 179 | +<footer role="contentinfo"> |
| 180 | +<hr> |
| 181 | +<p class="legal-copy"><small>Copyright © 2026. All rights reserved.</small></p> |
| 182 | +</footer> |
| 183 | +</div> |
| 184 | +</div> |
| 185 | +</body> |
| 186 | +</html> |
0 commit comments