Ice 3.8
C++ API Reference
Loading...
Searching...
No Matches
LocalExceptions.h
1// Copyright (c) ZeroC, Inc.
2
3#ifndef ICE_LOCAL_EXCEPTIONS_H
4#define ICE_LOCAL_EXCEPTIONS_H
5
6#include "Ice/Identity.h"
7#include "Ice/ReplyStatus.h"
8#include "LocalException.h"
9
10#include <memory>
11#include <optional>
12#include <string>
13#include <string_view>
14#include <utility>
15
16// This file contains most exceptions derived from Ice::LocalException.
17
18namespace Ice
19{
20 class ObjectPrx;
21
22 //
23 // Dispatch exceptions
24 //
25
26 /// The exception that is thrown when a dispatch failed. This is the base class for local exceptions that can be
27 /// marshaled and transmitted "over the wire".
28 /// You can throw this exception in the implementation of an operation, or in a middleware. The Ice runtime then
29 /// logically rethrows this exception to the client.
30 /// @headerfile Ice/Ice.h
31 class ICE_API DispatchException : public LocalException
32 {
33 public:
34 /// Constructs a DispatchException.
35 /// @param file The file where this exception is constructed. This C string is not copied.
36 /// @param line The line where this exception is constructed.
37 /// @param replyStatus The reply status. It must be greater than ReplyStatus::UserException.
38 /// @param message The error message. If nullopt, this constructor creates a default message.
40 const char* file,
41 int line,
43 std::optional<std::string> message = std::nullopt);
44
45 /// Gets the reply status.
46 /// @return The reply status.
47 [[nodiscard]] ReplyStatus replyStatus() const noexcept { return _replyStatus; }
48
49 [[nodiscard]] const char* ice_id() const noexcept override;
50
51 private:
52 ReplyStatus _replyStatus;
53 };
54
55 /// The base class for the 3 NotExist exceptions.
56 /// @headerfile Ice/Ice.h
58 {
59 public:
60 /// The identity of the Ice Object to which the request was sent.
61 [[nodiscard]] const Identity& id() const noexcept { return *_id; }
62
63 /// The facet to which the request was sent.
64 [[nodiscard]] const std::string& facet() const noexcept { return *_facet; }
65
66 /// The operation name of the request.
67 [[nodiscard]] const std::string& operation() const noexcept { return *_operation; }
68
69 protected:
70 /// @cond INTERNAL
71 /// Constructs a RequestFailedException with a custom error message.
72 /// @param file The file where this exception is constructed. This C string is not copied.
73 /// @param line The line where this exception is constructed.
74 /// @param replyStatus The reply status.
75 /// @param id The identity of the Ice Object to which the request was sent.
76 /// @param facet The facet to which the request was sent.
77 /// @param operation The operation name of the request.
79 const char* file,
80 int line,
81 ReplyStatus replyStatus,
82 Identity id,
83 std::string facet,
84 std::string operation);
85
86 /// Constructs a RequestFailedException without specifying the details of the current request. The details will
87 /// be filled-in automatically by the Ice runtime before marshaling the exception.
88 /// @param file The file where this exception is constructed. This C string is not copied.
89 /// @param line The line where this exception is constructed.
90 /// @param replyStatus The reply status.
91 RequestFailedException(const char* file, int line, ReplyStatus replyStatus);
92
93 RequestFailedException(const RequestFailedException&) noexcept = default;
94 RequestFailedException& operator=(const RequestFailedException&) noexcept = default;
95 ~RequestFailedException() override; // to avoid weak vtable
96 /// @endcond
97
98 private:
99 std::shared_ptr<Identity> _id;
100 std::shared_ptr<std::string> _facet;
101 std::shared_ptr<std::string> _operation;
102 };
103
104 /// The exception that is thrown when a dispatch could not find a servant for the identity carried by the request.
105 /// @headerfile Ice/Ice.h
107 {
108 public:
109 /// Constructs an ObjectNotExistException.
110 /// @param file The file where this exception is constructed. This C string is not copied.
111 /// @param line The line where this exception is constructed.
112 /// @param id The identity of the Ice Object to which the request was sent.
113 /// @param facet The facet to which the request was sent.
114 /// @param operation The operation name of the request.
115 ObjectNotExistException(const char* file, int line, Identity id, std::string facet, std::string operation);
116
117 /// Constructs an ObjectNotExistException without specifying the details of the current request. The details
118 /// will be filled-in automatically by the Ice runtime before marshaling the exception.
119 /// @param file The file where this exception is constructed. This C string is not copied.
120 /// @param line The line where this exception is constructed.
121 ObjectNotExistException(const char* file, int line);
122
123 [[nodiscard]] const char* ice_id() const noexcept final;
124 };
125
126 /// The exception that is thrown when a dispatch could not find a servant for the identity + facet carried by the
127 /// request.
128 /// @headerfile Ice/Ice.h
130 {
131 public:
132 /// Constructs a FacetNotExistException.
133 /// @param file The file where this exception is constructed. This C string is not copied.
134 /// @param line The line where this exception is constructed.
135 /// @param id The identity of the Ice Object to which the request was sent.
136 /// @param facet The facet to which the request was sent.
137 /// @param operation The operation name of the request.
138 FacetNotExistException(const char* file, int line, Identity id, std::string facet, std::string operation);
139
140 /// Constructs a FacetNotExistException without specifying the details of the current request. The details will
141 /// be filled-in automatically by the Ice runtime before marshaling the exception.
142 /// @param file The file where this exception is constructed. This C string is not copied.
143 /// @param line The line where this exception is constructed.
144 FacetNotExistException(const char* file, int line);
145
146 [[nodiscard]] const char* ice_id() const noexcept final;
147 };
148
149 /// The exception that is thrown when a dispatch could not find the operation carried by the request on the target
150 /// servant. This is typically due to a mismatch in the Slice definitions, such as the client using Slice
151 /// definitions newer than the server's.
152 /// @headerfile Ice/Ice.h
154 {
155 public:
156 /// Constructs an OperationNotExistException.
157 /// @param file The file where this exception is constructed. This C string is not copied.
158 /// @param line The line where this exception is constructed.
159 /// @param id The identity of the Ice Object to which the request was sent.
160 /// @param facet The facet to which the request was sent.
161 /// @param operation The operation name of the request.
162 OperationNotExistException(const char* file, int line, Identity id, std::string facet, std::string operation);
163
164 /// Constructs an OperationNotExistException without specifying the details of the current request. The details
165 /// will be filled-in automatically by the Ice runtime before marshaling the exception.
166 /// @param file The file where this exception is constructed. This C string is not copied.
167 /// @param line The line where this exception is constructed.
168 OperationNotExistException(const char* file, int line);
169
170 [[nodiscard]] const char* ice_id() const noexcept final;
171 };
172
173 /// The exception that is thrown when a dispatch failed with an exception that is not a LocalException or a
174 /// UserException.
175 /// @headerfile Ice/Ice.h
176 class ICE_API UnknownException : public DispatchException
177 {
178 public:
179 /// Constructs an UnknownException.
180 /// @param file The file where this exception is constructed. This C string is not copied.
181 /// @param line The line where this exception is constructed.
182 /// @param message The error message adopted by this exception and returned by what().
183 UnknownException(const char* file, int line, std::string message);
184
185 [[nodiscard]] const char* ice_id() const noexcept override;
186
187 protected:
188 /// Constructs an UnknownException.
189 /// @param file The file where this exception is constructed. This C string is not copied.
190 /// @param line The line where this exception is constructed.
191 /// @param replyStatus The reply status.
192 /// @param message The error message adopted by this exception and returned by what().
193 UnknownException(const char* file, int line, ReplyStatus replyStatus, std::string message);
194 };
195
196 /// The exception that is thrown when a dispatch failed with a LocalException that is not a DispatchException.
197 /// @headerfile Ice/Ice.h
198 class ICE_API UnknownLocalException final : public UnknownException
199 {
200 public:
201 /// Constructs an UnknownLocalException.
202 /// @param file The file where this exception is constructed. This C string is not copied.
203 /// @param line The line where this exception is constructed.
204 /// @param message The error message adopted by this exception and returned by what().
205 UnknownLocalException(const char* file, int line, std::string message);
206
207 [[nodiscard]] const char* ice_id() const noexcept final;
208 };
209
210 /// The exception that is thrown when a client receives a UserException that was not declared in the operation's
211 /// exception specification.
212 /// @headerfile Ice/Ice.h
213 class ICE_API UnknownUserException final : public UnknownException
214 {
215 public:
216 /// Constructs an UnknownUserException.
217 /// @param file The file where this exception is constructed. This C string is not copied.
218 /// @param line The line where this exception is constructed.
219 /// @param message The error message adopted by this exception and returned by what().
220 UnknownUserException(const char* file, int line, std::string message);
221
222 /// Creates an UnknownUserException from the type ID of an unexpected exception.
223 /// @param file The file where this exception is constructed. This C string is not copied.
224 /// @param line The line where this exception is constructed.
225 /// @param typeId The type ID.
226 static UnknownUserException fromTypeId(const char* file, int line, const char* typeId);
227
228 [[nodiscard]] const char* ice_id() const noexcept final;
229 };
230
231 //
232 // Protocol exceptions
233 //
234
235 /// The base class for exceptions related to the Ice protocol.
236 /// @headerfile Ice/Ice.h
237 class ICE_API ProtocolException : public LocalException
238 {
239 public:
241
242 [[nodiscard]] const char* ice_id() const noexcept override;
243 };
244
245 /// The exception that is thrown when the connection has been gracefully shut down by the server. The request
246 /// that returned this exception has not been executed by the server. In most cases you will not get this exception,
247 /// because the client will automatically retry the invocation. However, if upon retry the server shuts down the
248 /// connection again, and the retry limit has been reached, then this exception is propagated to the application
249 /// code.
250 /// @headerfile Ice/Ice.h
251 class ICE_API CloseConnectionException final : public ProtocolException
252 {
253 public:
254 /// Constructs a CloseConnectionException.
255 /// @param file The file where this exception is constructed. This C string is not copied.
256 /// @param line The line where this exception is constructed.
257 CloseConnectionException(const char* file, int line)
258 : ProtocolException(file, line, "connection closed by the peer")
259 {
260 }
261
262 [[nodiscard]] const char* ice_id() const noexcept final;
263 };
264
265 /// The exception that is thrown when a datagram exceeds the configured send or receive buffer size, or exceeds the
266 /// maximum payload size of a UDP packet (65507 bytes).
267 /// @headerfile Ice/Ice.h
268 class ICE_API DatagramLimitException final : public ProtocolException
269 {
270 public:
271 /// Constructs a DatagramLimitException.
272 /// @param file The file where this exception is constructed. This C string is not copied.
273 /// @param line The line where this exception is constructed.
274 DatagramLimitException(const char* file, int line)
275 : ProtocolException(file, line, "datagram size exceeds configured limit")
276 {
277 }
278
279 [[nodiscard]] const char* ice_id() const noexcept final;
280 };
281
282 /// The exception that is thrown when an error occurs during marshaling or unmarshaling.
283 /// @headerfile Ice/Ice.h
284 class ICE_API MarshalException final : public ProtocolException
285 {
286 public:
287 using ProtocolException::ProtocolException;
288
289 [[nodiscard]] const char* ice_id() const noexcept final;
290 };
291
292 //
293 // Timeout exceptions
294 //
295
296 /// The exception that is thrown when a timeout occurs. This is the base class for all timeout exceptions.
297 /// @headerfile Ice/Ice.h
298 class ICE_API TimeoutException : public LocalException
299 {
300 public:
302
303 [[nodiscard]] const char* ice_id() const noexcept override;
304 };
305
306 /// The exception that is thrown when a connection establishment times out.
307 /// @headerfile Ice/Ice.h
308 class ICE_API ConnectTimeoutException final : public TimeoutException
309 {
310 public:
311 /// Constructs a ConnectTimeoutException.
312 /// @param file The file where this exception is constructed. This C string is not copied.
313 /// @param line The line where this exception is constructed.
314 ConnectTimeoutException(const char* file, int line)
315 : TimeoutException(file, line, "connection establishment timed out")
316 {
317 }
318
319 [[nodiscard]] const char* ice_id() const noexcept final;
320 };
321
322 /// The exception that is thrown when a graceful connection closure times out.
323 /// @headerfile Ice/Ice.h
324 class ICE_API CloseTimeoutException final : public TimeoutException
325 {
326 public:
327 /// Constructs a CloseTimeoutException.
328 /// @param file The file where this exception is constructed. This C string is not copied.
329 /// @param line The line where this exception is constructed.
330 CloseTimeoutException(const char* file, int line)
331 : TimeoutException(file, line, "graceful connection closure timed out")
332 {
333 }
334
335 [[nodiscard]] const char* ice_id() const noexcept final;
336 };
337
338 /// The exception that is thrown when an invocation times out.
339 /// @headerfile Ice/Ice.h
340 class ICE_API InvocationTimeoutException final : public TimeoutException
341 {
342 public:
343 /// Constructs an InvocationTimeoutException.
344 /// @param file The file where this exception is constructed. This C string is not copied.
345 /// @param line The line where this exception is constructed.
346 InvocationTimeoutException(const char* file, int line) : TimeoutException(file, line, "invocation timed out") {}
347
348 [[nodiscard]] const char* ice_id() const noexcept final;
349 };
350
351 //
352 // Syscall exceptions
353 //
354
355 /// The exception that is thrown to report the failure of a system call.
356 /// @headerfile Ice/Ice.h
357 class ICE_API SyscallException : public LocalException
358 {
359 public:
360 /// The error code is a DWORD (unsigned long) on Windows and an int on other platforms.
361#ifdef _WIN32
362 using ErrorCode = unsigned long;
363#else
364 using ErrorCode = int;
365#endif
366
367 /// Constructs a SyscallException.
368 /// @param file The file where this exception is constructed. This C string is not copied.
369 /// @param line The line where this exception is constructed.
370 /// @param messagePrefix The start of the message returned by what().
371 /// @param error The error code.
372 SyscallException(const char* file, int line, std::string messagePrefix, ErrorCode error);
373
374 /// Gets the error number describing the system exception. On Unix, this is equivalent to
375 /// <code>errno</code>. On Windows, this is the value returned by <code>GetLastError()</code> or
376 /// <code>WSAGetLastError()</code>.
377 [[nodiscard]] ErrorCode error() const noexcept { return _error; }
378
379 [[nodiscard]] const char* ice_id() const noexcept override;
380
381 protected:
382 /// Constructs a SyscallException.
383 /// @param file The file where this exception is constructed. This C string is not copied.
384 /// @param line The line where this exception is constructed.
385 /// @param messagePrefix The start of the message returned by what().
386 /// @param error The error code.
387 /// @param errorToString A function that converts the error code to a string.
389 const char* file,
390 int line,
391 std::string messagePrefix,
393 const std::function<std::string(ErrorCode)>& errorToString);
394
395 /// Constructs a SyscallException without an error.
396 /// @param file The file where this exception is constructed. This C string is not copied.
397 /// @param line The line where this exception is constructed.
398 /// @param message The message returned by what().
399 SyscallException(const char* file, int line, std::string message)
400 : LocalException(file, line, std::move(message)),
401 _error(0)
402 {
403 }
404
405 private:
406 ErrorCode _error;
407 };
408
409 /// The exception that is thrown to report a DNS resolution failure.
410 /// @headerfile Ice/Ice.h
411 class ICE_API DNSException final : public SyscallException
412 {
413 public:
414 /// Constructs a DNSException.
415 /// @param file The file where this exception is constructed. This C string is not copied.
416 /// @param line The line where this exception is constructed.
417 /// @param error The error code.
418 /// @param host The host name that could not be resolved.
419 DNSException(const char* file, int line, ErrorCode error, std::string_view host);
420
421 [[nodiscard]] const char* ice_id() const noexcept final;
422 };
423
424 /// The exception that is thrown to report a file system error.
425 /// @headerfile Ice/Ice.h
426 class ICE_API FileException final : public SyscallException
427 {
428 public:
429 /// Constructs a FileException.
430 /// @param file The file where this exception is constructed. This C string is not copied.
431 /// @param line The line where this exception is constructed.
432 /// @param path The path of the file that caused the exception.
433 /// @param error The error code.
434 FileException(const char* file, int line, std::string_view path, ErrorCode error = 0);
435
436 [[nodiscard]] const char* ice_id() const noexcept final;
437 };
438
439 //
440 // Socket exceptions
441 //
442
443 /// The exception that is thrown to report a socket error.
444 /// @headerfile Ice/Ice.h
445 class ICE_API SocketException : public SyscallException
446 {
447 public:
448 /// Constructs a SocketException.
449 /// @param file The file where this exception is constructed. This C string is not copied.
450 /// @param line The line where this exception is constructed.
451 /// @param messagePrefix The start of the message returned by what().
452 /// @param error The error code.
453 SocketException(const char* file, int line, std::string messagePrefix, ErrorCode error);
454
455 /// Constructs a SocketException with a generic message.
456 /// @param file The file where this exception is constructed. This C string is not copied.
457 /// @param line The line where this exception is constructed.
458 /// @param error The error code.
459 SocketException(const char* file, int line, ErrorCode error)
460 : SocketException(file, line, "socket error", error)
461 {
462 }
463
464 /// Constructs a SocketException without an error.
465 /// @param file The file where this exception is constructed. This C string is not copied.
466 /// @param line The line where this exception is constructed.
467 /// @param message The message returned by what().
468 SocketException(const char* file, int line, std::string message)
469 : SyscallException(file, line, std::move(message))
470 {
471 }
472
473 [[nodiscard]] const char* ice_id() const noexcept override;
474
475 protected:
477 };
478
479 /// The exception that is thrown when a connection establishment fails.
480 /// @headerfile Ice/Ice.h
482 {
483 public:
484 /// Constructs a ConnectFailedException.
485 /// @param file The file where this exception is constructed. This C string is not copied.
486 /// @param line The line where this exception is constructed.
487 /// @param messagePrefix The start of the message returned by what().
488 /// @param error The error code.
489 /// @param address The address of the remote peer, if available.
491 const char* file,
492 int line,
493 std::string messagePrefix,
495 std::optional<std::string> address = std::nullopt);
496
497 /// Constructs a ConnectFailedException with a generic message and an error code.
498 /// @param file The file where this exception is constructed. This C string is not copied.
499 /// @param line The line where this exception is constructed.
500 /// @param error The error code.
501 /// @param address The address of the remote peer, if available.
503 const char* file,
504 int line,
506 std::optional<std::string> address = std::nullopt)
507 : ConnectFailedException{file, line, "connect failed", error, std::move(address)}
508 {
509 }
510
511 /// Constructs a ConnectFailedException without an error code.
512 /// @param file The file where this exception is constructed. This C string is not copied.
513 /// @param line The line where this exception is constructed.
514 /// @param message The message returned by what().
515 ConnectFailedException(const char* file, int line, std::string message)
516 : SocketException(file, line, std::move(message))
517 {
518 }
519
520 [[nodiscard]] const char* ice_id() const noexcept override;
521 };
522
523 /// The exception that is thrown when an established connection is lost.
524 /// @headerfile Ice/Ice.h
525 class ICE_API ConnectionLostException final : public SocketException
526 {
527 public:
528 /// Constructs a ConnectionLostException.
529 /// @param file The file where this exception is constructed. This C string is not copied.
530 /// @param line The line where this exception is constructed.
531 /// @param error The error code.
532 /// @param address The address of the remote peer, if available.
534 const char* file,
535 int line,
537 std::optional<std::string> address = std::nullopt);
538
539 /// Constructs a ConnectionLostException without an error code.
540 /// @param file The file where this exception is constructed. This C string is not copied.
541 /// @param line The line where this exception is constructed.
542 /// @param address The address of the remote peer, if available.
543 ConnectionLostException(const char* file, int line, std::optional<std::string> address = std::nullopt);
544
545 [[nodiscard]] const char* ice_id() const noexcept final;
546 };
547
548 /// The exception that is thrown when the server host actively refuses a connection.
549 /// @headerfile Ice/Ice.h
551 {
552 public:
553 /// Constructs a ConnectionRefusedException.
554 /// @param file The file where this exception is constructed. This C string is not copied.
555 /// @param line The line where this exception is constructed.
556 /// @param address The address of the remote peer, if available.
557 ConnectionRefusedException(const char* file, int line, std::optional<std::string> address = std::nullopt);
558
559 [[nodiscard]] const char* ice_id() const noexcept final;
560 };
561
562 //
563 // Other leaf local exceptions in alphabetical order.
564 //
565
566 /// The exception that is thrown when you attempt to register an object more than once with the Ice runtime.
567 /// @headerfile Ice/Ice.h
568 class ICE_API AlreadyRegisteredException final : public LocalException
569 {
570 public:
571 /// Constructs a AlreadyRegisteredException.
572 /// @param file The file where this exception is constructed. This C string is not copied.
573 /// @param line The line where this exception is constructed.
574 /// @param kindOfObject The kind of object that is already registered.
575 /// @param id The ID (or name) of the object that is already registered.
576 AlreadyRegisteredException(const char* file, int line, std::string kindOfObject, std::string id);
577
578 /// Gets the kind of object that is already registered: "servant", "facet", "object", "default servant",
579 /// "servant locator", "plugin", "object adapter", "object adapter with router", "replica group".
580 [[nodiscard]] const std::string& kindOfObject() const noexcept { return *_kindOfObject; }
581
582 /// Gets the ID (or name) of the object that is already registered.
583 [[nodiscard]] const std::string& id() const noexcept { return *_id; }
584
585 [[nodiscard]] const char* ice_id() const noexcept final;
586
587 private:
588 std::shared_ptr<std::string> _kindOfObject;
589 std::shared_ptr<std::string> _id;
590 };
591
592 /// The exception that is thrown when an operation fails because the communicator has been destroyed.
593 /// @see Communicator#destroy
594 /// @headerfile Ice/Ice.h
596 {
597 public:
598 /// Constructs a CommunicatorDestroyedException.
599 /// @param file The file where this exception is constructed. This C string is not copied.
600 /// @param line The line where this exception is constructed.
601 CommunicatorDestroyedException(const char* file, int line)
602 : LocalException(file, line, "the Ice communicator object is destroyed")
603 {
604 }
605
606 [[nodiscard]] const char* ice_id() const noexcept final;
607 };
608
609 /// The exception that is thrown when an operation fails because the connection has been aborted.
610 /// @headerfile Ice/Ice.h
611 class ICE_API ConnectionAbortedException final : public LocalException
612 {
613 public:
614 /// Constructs a ConnectionAbortedException.
615 /// @param file The file where this exception is constructed. This C string is not copied.
616 /// @param line The line where this exception is constructed.
617 /// @param message The message returned by what().
618 /// @param closedByApplication True if the connection was aborted by the application, false if the connection
619 /// was aborted by the Ice runtime.
620 ConnectionAbortedException(const char* file, int line, std::string message, bool closedByApplication)
621 : LocalException(file, line, std::move(message)),
622 _closedByApplication(closedByApplication)
623 {
624 }
625
626 /// Returns true if the connection was aborted by the application, false if it was aborted by the Ice runtime.
627 [[nodiscard]] bool closedByApplication() const noexcept { return _closedByApplication; }
628
629 [[nodiscard]] const char* ice_id() const noexcept final;
630
631 private:
632 bool _closedByApplication;
633 };
634
635 /// The exception that is thrown when an operation fails because the connection has been closed gracefully.
636 /// @headerfile Ice/Ice.h
637 class ICE_API ConnectionClosedException final : public LocalException
638 {
639 public:
640 /// Constructs a ConnectionClosedException.
641 /// @param file The file where this exception is constructed. This C string is not copied.
642 /// @param line The line where this exception is constructed.
643 /// @param message The message returned by what().
644 /// @param closedByApplication True if the connection was closed by the application, false if the connection was
645 /// closed by the Ice runtime.
646 ConnectionClosedException(const char* file, int line, std::string message, bool closedByApplication)
647 : LocalException(file, line, std::move(message)),
648 _closedByApplication(closedByApplication)
649 {
650 }
651
652 /// Returns true if the connection was closed by the application, false if it was closed by the Ice runtime.
653 [[nodiscard]] bool closedByApplication() const noexcept { return _closedByApplication; }
654
655 [[nodiscard]] const char* ice_id() const noexcept final;
656
657 private:
658 bool _closedByApplication;
659 };
660
661 /// The exception that is thrown when attempting to use an unsupported feature.
662 /// @headerfile Ice/Ice.h
663 class ICE_API FeatureNotSupportedException final : public LocalException
664 {
665 public:
667
668 [[nodiscard]] const char* ice_id() const noexcept final;
669 };
670
671 /// The exception that is thrown when attempting to change a connection-related property on a fixed proxy.
672 /// @headerfile Ice/Ice.h
673 class ICE_API FixedProxyException final : public LocalException
674 {
675 public:
676 /// Constructs a FixedProxyException.
677 /// @param file The file where this exception is constructed. This C string is not copied.
678 /// @param line The line where this exception is constructed.
679 FixedProxyException(const char* file, int line)
680 : LocalException(file, line, "cannot change the properties of a fixed proxy")
681 {
682 }
683
684 [[nodiscard]] const char* ice_id() const noexcept final;
685 };
686
687 /// The exception that is thrown when communicator initialization fails.
688 /// @headerfile Ice/Ice.h
689 class ICE_API InitializationException final : public LocalException
690 {
691 public:
693
694 [[nodiscard]] const char* ice_id() const noexcept final;
695 };
696
697 /// The exception that is thrown when an asynchronous invocation fails because it was canceled explicitly by the
698 /// user.
699 /// @headerfile Ice/Ice.h
700 class ICE_API InvocationCanceledException final : public LocalException
701 {
702 public:
703 /// Constructs an InvocationCanceledException.
704 /// @param file The file where this exception is constructed. This C string is not copied.
705 /// @param line The line where this exception is constructed.
706 InvocationCanceledException(const char* file, int line) : LocalException(file, line, "invocation canceled") {}
707
708 [[nodiscard]] const char* ice_id() const noexcept final;
709 };
710
711 /// The exception that is thrown when the Ice runtime cannot find a suitable endpoint to connect to.
712 /// @headerfile Ice/Ice.h
713 class ICE_API NoEndpointException final : public LocalException
714 {
715 public:
717
718 /// Constructs a NoEndpointException.
719 /// @param file The file where this exception is constructed. This C string is not copied.
720 /// @param line The line where this exception is constructed.
721 /// @param proxy The proxy used to create the message return by what().
722 NoEndpointException(const char* file, int line, const ObjectPrx& proxy);
723
724 [[nodiscard]] const char* ice_id() const noexcept final;
725 };
726
727 /// The exception that is thrown when attempting to find or deregister something that is not registered with Ice.
728 /// @headerfile Ice/Ice.h
729 class ICE_API NotRegisteredException final : public LocalException
730 {
731 public:
732 /// Constructs a NotRegisteredException.
733 /// @param file The file where this exception is constructed. This C string is not copied.
734 /// @param line The line where this exception is constructed.
735 /// @param kindOfObject The kind of object that is not registered.
736 /// @param id The ID (or name) of the object that is not registered.
737 NotRegisteredException(const char* file, int line, std::string kindOfObject, std::string id);
738
739 /// Gets the kind of object that is not registered.
740 [[nodiscard]] const std::string& kindOfObject() const noexcept { return *_kindOfObject; }
741
742 /// Gets the ID (or name) of the object that is not registered.
743 [[nodiscard]] const std::string& id() const noexcept { return *_id; };
744
745 [[nodiscard]] const char* ice_id() const noexcept final;
746
747 private:
748 std::shared_ptr<std::string> _kindOfObject;
749 std::shared_ptr<std::string> _id;
750 };
751
752 /// The exception that is thrown when attempting to use an ObjectAdapter that has been deactivated.
753 /// @see ObjectAdapter#deactivate
754 /// @see Communicator#shutdown
755 /// @headerfile Ice/Ice.h
757 {
758 public:
759 /// Constructs an ObjectAdapterDeactivatedException.
760 /// @param file The file where this exception is constructed. This C string is not copied.
761 /// @param line The line where this exception is constructed.
762 /// @param name The name of the object adapter that is deactivated.
763 ObjectAdapterDeactivatedException(const char* file, int line, std::string_view name)
764 : LocalException(file, line, "object adapter '" + std::string{name} + "' is deactivated")
765 {
766 }
767
768 [[nodiscard]] const char* ice_id() const noexcept final;
769 };
770
771 /// The exception that is thrown when attempting to use an ObjectAdapter that has been destroyed.
772 /// @headerfile Ice/Ice.h
774 {
775 public:
776 /// Constructs an ObjectAdapterDestroyedException.
777 /// @param file The file where this exception is constructed. This C string is not copied.
778 /// @param line The line where this exception is constructed.
779 /// @param name The name of the object adapter that is destroyed.
780 ObjectAdapterDestroyedException(const char* file, int line, std::string_view name)
781 : LocalException(file, line, "object adapter '" + std::string{name} + "' is destroyed")
782 {
783 }
784
785 [[nodiscard]] const char* ice_id() const noexcept final;
786 };
787
788 /// The exception that is thrown when an ObjectAdapter cannot be activated. This can happen when the locator
789 /// implementation detects another active ObjectAdapter with the same adapter ID.
790 /// @headerfile Ice/Ice.h
792 {
793 public:
794 /// Constructs an ObjectAdapterIdInUseException.
795 /// @param file The file where this exception is constructed. This C string is not copied.
796 /// @param line The line where this exception is constructed.
797 /// @param adapterId The adapter ID used to create the message returned by what().
798 ObjectAdapterIdInUseException(const char* file, int line, std::string_view adapterId)
799 : LocalException(file, line, "an object adapter with ID '" + std::string{adapterId} + "' is already active")
800 {
801 }
802
803 [[nodiscard]] const char* ice_id() const noexcept final;
804 };
805
806 /// The exception that is thrown when the parsing of a string fails.
807 /// @headerfile Ice/Ice.h
808 class ICE_API ParseException final : public LocalException
809 {
810 public:
812
813 [[nodiscard]] const char* ice_id() const noexcept final;
814 };
815
816 /// The exception that is thrown when the initialization of an Ice plugin fails.
817 /// @headerfile Ice/Ice.h
819 {
820 public:
822
823 [[nodiscard]] const char* ice_id() const noexcept final;
824 };
825
826 /// The exception that is thrown when a failure occurs in the security subsystem. This includes IceSSL errors.
827 /// @headerfile Ice/Ice.h
828 class ICE_API SecurityException final : public LocalException
829 {
830 public:
832
833 [[nodiscard]] const char* ice_id() const noexcept final;
834 };
835
836 /// The exception that is thrown when attempting to invoke an operation with `ice_oneway`, `ice_batchOneway`,
837 /// `ice_datagram`, or `ice_batchDatagram`, and the operation has a return value, an out parameter, or an exception
838 /// specification.
839 /// @headerfile Ice/Ice.h
840 class ICE_API TwowayOnlyException final : public LocalException
841 {
842 public:
843 /// Constructs a TwowayOnlyException.
844 /// @param file The file where this exception is constructed. This C string is not copied.
845 /// @param line The line where this exception is constructed.
846 /// @param operation The two-way only operation used to create the message returned by what().
847 TwowayOnlyException(const char* file, int line, std::string_view operation)
849 file,
850 line,
851 "cannot invoke operation '" + std::string{operation} +
852 "' with a oneway, batchOneway, datagram, or batchDatagram proxy")
853 {
854 }
855
856 [[nodiscard]] const char* ice_id() const noexcept final;
857 };
858
859 /// The exception that is thrown when a property cannot be set or retrieved. For example, this exception is thrown
860 /// when attempting to set an unknown Ice property.
861 class ICE_API PropertyException final : public LocalException
862 {
863 public:
865
866 [[nodiscard]] const char* ice_id() const noexcept final;
867 };
868}
869
870#endif
const std::string & id() const noexcept
Gets the ID (or name) of the object that is already registered.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
AlreadyRegisteredException(const char *file, int line, std::string kindOfObject, std::string id)
Constructs a AlreadyRegisteredException.
const std::string & kindOfObject() const noexcept
Gets the kind of object that is already registered: "servant", "facet", "object", "default servant",...
CloseConnectionException(const char *file, int line)
Constructs a CloseConnectionException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
CloseTimeoutException(const char *file, int line)
Constructs a CloseTimeoutException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
CommunicatorDestroyedException(const char *file, int line)
Constructs a CommunicatorDestroyedException.
ConnectFailedException(const char *file, int line, ErrorCode error, std::optional< std::string > address=std::nullopt)
Constructs a ConnectFailedException with a generic message and an error code.
ConnectFailedException(const char *file, int line, std::string message)
Constructs a ConnectFailedException without an error code.
ConnectFailedException(const char *file, int line, std::string messagePrefix, ErrorCode error, std::optional< std::string > address=std::nullopt)
Constructs a ConnectFailedException.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ConnectTimeoutException(const char *file, int line)
Constructs a ConnectTimeoutException.
ConnectionAbortedException(const char *file, int line, std::string message, bool closedByApplication)
Constructs a ConnectionAbortedException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
bool closedByApplication() const noexcept
Returns true if the connection was aborted by the application, false if it was aborted by the Ice run...
bool closedByApplication() const noexcept
Returns true if the connection was closed by the application, false if it was closed by the Ice runti...
ConnectionClosedException(const char *file, int line, std::string message, bool closedByApplication)
Constructs a ConnectionClosedException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ConnectionLostException(const char *file, int line, ErrorCode error, std::optional< std::string > address=std::nullopt)
Constructs a ConnectionLostException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ConnectionLostException(const char *file, int line, std::optional< std::string > address=std::nullopt)
Constructs a ConnectionLostException without an error code.
ConnectionRefusedException(const char *file, int line, std::optional< std::string > address=std::nullopt)
Constructs a ConnectionRefusedException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
DNSException(const char *file, int line, ErrorCode error, std::string_view host)
Constructs a DNSException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
DatagramLimitException(const char *file, int line)
Constructs a DatagramLimitException.
DispatchException(const char *file, int line, ReplyStatus replyStatus, std::optional< std::string > message=std::nullopt)
Constructs a DispatchException.
ReplyStatus replyStatus() const noexcept
Gets the reply status.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
FacetNotExistException(const char *file, int line)
Constructs a FacetNotExistException without specifying the details of the current request.
FacetNotExistException(const char *file, int line, Identity id, std::string facet, std::string operation)
Constructs a FacetNotExistException.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
The exception that is thrown when attempting to use an unsupported feature.
FileException(const char *file, int line, std::string_view path, ErrorCode error=0)
Constructs a FileException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
FixedProxyException(const char *file, int line)
Constructs a FixedProxyException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
The exception that is thrown when communicator initialization fails.
InvocationCanceledException(const char *file, int line)
Constructs an InvocationCanceledException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
InvocationTimeoutException(const char *file, int line)
Constructs an InvocationTimeoutException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
The exception that is thrown when an error occurs during marshaling or unmarshaling.
NoEndpointException(const char *file, int line, const ObjectPrx &proxy)
Constructs a NoEndpointException.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
const std::string & kindOfObject() const noexcept
Gets the kind of object that is not registered.
NotRegisteredException(const char *file, int line, std::string kindOfObject, std::string id)
Constructs a NotRegisteredException.
const std::string & id() const noexcept
Gets the ID (or name) of the object that is not registered.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ObjectAdapterDeactivatedException(const char *file, int line, std::string_view name)
Constructs an ObjectAdapterDeactivatedException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ObjectAdapterDestroyedException(const char *file, int line, std::string_view name)
Constructs an ObjectAdapterDestroyedException.
ObjectAdapterIdInUseException(const char *file, int line, std::string_view adapterId)
Constructs an ObjectAdapterIdInUseException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ObjectNotExistException(const char *file, int line)
Constructs an ObjectNotExistException without specifying the details of the current request.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
ObjectNotExistException(const char *file, int line, Identity id, std::string facet, std::string operation)
Constructs an ObjectNotExistException.
The base class for all Ice proxies.
Definition Proxy.h:232
const char * ice_id() const noexcept final
Returns the type ID of this exception.
OperationNotExistException(const char *file, int line)
Constructs an OperationNotExistException without specifying the details of the current request.
OperationNotExistException(const char *file, int line, Identity id, std::string facet, std::string operation)
Constructs an OperationNotExistException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
The exception that is thrown when the parsing of a string fails.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
The exception that is thrown when the initialization of an Ice plugin fails.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
The exception that is thrown when a property cannot be set or retrieved.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
The base class for exceptions related to the Ice protocol.
const std::string & operation() const noexcept
The operation name of the request.
const Identity & id() const noexcept
The identity of the Ice Object to which the request was sent.
const std::string & facet() const noexcept
The facet to which the request was sent.
The base class for the 3 NotExist exceptions.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
The exception that is thrown when a failure occurs in the security subsystem.
SocketException(const char *file, int line, std::string messagePrefix, ErrorCode error)
Constructs a SocketException.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
SocketException(const char *file, int line, std::string message)
Constructs a SocketException without an error.
SyscallException(const char *file, int line, std::string messagePrefix, ErrorCode error)
Constructs a SyscallException.
SocketException(const char *file, int line, ErrorCode error)
Constructs a SocketException with a generic message.
int ErrorCode
The error code is a DWORD (unsigned long) on Windows and an int on other platforms.
ErrorCode error() const noexcept
Gets the error number describing the system exception.
SyscallException(const char *file, int line, std::string messagePrefix, ErrorCode error)
Constructs a SyscallException.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
LocalException(const char *file, int line, std::string message)
Constructs a local exception.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
The exception that is thrown when a timeout occurs.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
TwowayOnlyException(const char *file, int line, std::string_view operation)
Constructs a TwowayOnlyException.
UnknownException(const char *file, int line, std::string message)
Constructs an UnknownException.
const char * ice_id() const noexcept override
Returns the type ID of this exception.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
UnknownLocalException(const char *file, int line, std::string message)
Constructs an UnknownLocalException.
const char * ice_id() const noexcept final
Returns the type ID of this exception.
UnknownUserException(const char *file, int line, std::string message)
Constructs an UnknownUserException.
static UnknownUserException fromTypeId(const char *file, int line, const char *typeId)
Creates an UnknownUserException from the type ID of an unexpected exception.
ReplyStatus
Represents the status of a reply.
Definition ReplyStatus.h:29
The Ice RPC framework.
Definition SampleEvent.h:60
Represents the identity of an Ice object.
Definition Identity.h:41