From 686fd4a2cd8a551999527a8149d78dd07c5973e0 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 13:27:56 -0400 Subject: [PATCH 01/21] Initial local exception refactoring --- csharp/src/Ice/DispatchExceptions.cs | 145 ++ csharp/src/Ice/Exception.cs | 53 +- csharp/src/Ice/Internal/OutgoingAsync.cs | 10 +- csharp/src/Ice/LocalException.cs | 2038 +---------------- csharp/src/Ice/LocalExceptions.cs | 1785 +++++++++++++++ csharp/src/Ice/UserException.cs | 38 + .../Ice/servantLocator/ServantLocatorAMDI.cs | 12 +- .../Ice/servantLocator/ServantLocatorI.cs | 12 +- 8 files changed, 2003 insertions(+), 2090 deletions(-) create mode 100644 csharp/src/Ice/DispatchExceptions.cs create mode 100644 csharp/src/Ice/LocalExceptions.cs create mode 100644 csharp/src/Ice/UserException.cs diff --git a/csharp/src/Ice/DispatchExceptions.cs b/csharp/src/Ice/DispatchExceptions.cs new file mode 100644 index 00000000000..483de3896c0 --- /dev/null +++ b/csharp/src/Ice/DispatchExceptions.cs @@ -0,0 +1,145 @@ +// Copyright (c) ZeroC, Inc. + +#nullable enable + +namespace Ice; + +// This file contains the 6 special local exceptions that can be marshaled in an Ice reply message. + +/// +/// The base exception for the 3 NotExist exceptions. +/// +public class RequestFailedException : LocalException +{ + public Identity id; + public string facet; + public string operation; + + protected RequestFailedException( + Identity id, + string facet, + string operation, + System.Exception? innerException = null) + : base(message: null, innerException) + { + this.id = id; + this.facet = facet; + this.operation = operation; + } +} + +/// +/// The dispatch could not find a servant for the identity carried by the request. +/// +public class ObjectNotExistException : RequestFailedException +{ + public ObjectNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) + { + } + + public ObjectNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) + { + } + + public override string ice_id() + { + return "::Ice::ObjectNotExistException"; + } +} + +/// +/// The dispatch could not find a servant for the identity + facet carried by the request. +/// +public class FacetNotExistException : RequestFailedException +{ + public FacetNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) + { + } + + public FacetNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) + { + } + + public override string ice_id() + { + return "::Ice::FacetNotExistException"; + } +} + +/// +/// The dispatch could not find the operation carried by the request on the target servant. This is typically due +/// to a mismatch in the Slice definitions, such as the client using Slice definitions newer than the server's. +/// +public class OperationNotExistException : RequestFailedException +{ + public OperationNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) + { + } + + public OperationNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) + { + } + + public override string ice_id() + { + return "::Ice::OperationNotExistException"; + } +} + +/// +/// The dispatch failed with an exception that is not a or a . +/// +public class UnknownException : LocalException +{ + public string unknown => Message; + + public UnknownException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() + { + return "::Ice::UnknownException"; + } +} + +/// +/// The dispatch failed with a that is not one of the special marshal-able local +/// exception. +/// +public class UnknownLocalException : UnknownException +{ + public UnknownLocalException(string message, LocalException? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() + { + return "::Ice::UnknownLocalException"; + } +} + +/// +/// The dispatch returned a that was not declared in the operation's exception +/// specification. +/// +public class UnknownUserException : UnknownException +{ + public UnknownUserException(string message) + : base(message, innerException: null) + { + } + + public override string ice_id() + { + return "::Ice::UnknownUserException"; + } +} diff --git a/csharp/src/Ice/Exception.cs b/csharp/src/Ice/Exception.cs index 00d72e6290f..fdbcde294d5 100644 --- a/csharp/src/Ice/Exception.cs +++ b/csharp/src/Ice/Exception.cs @@ -5,62 +5,23 @@ namespace Ice; /// -/// Base class for Ice exceptions. +/// Base class for all Ice exceptions. /// public abstract class Exception : System.Exception { /// - /// Returns the type id of this exception. + /// Returns the type ID of this exception. /// - /// The type id of this exception. + /// The type ID of this exception. public abstract string ice_id(); /// - /// Constructs an Ice exception with an optional inner exception. + /// Constructs an Ice exception. /// + /// The exception message. /// The inner exception. - protected Exception(System.Exception? innerException = null) : base("", innerException) { } -} - -/// -/// Base class for Ice run-time exceptions. -/// -public abstract class LocalException : Exception -{ - /// - /// Constructs an Ice local exception with an optional inner exception. - /// - /// The inner exception. - protected LocalException(System.Exception? innerException = null) : base(innerException) { } -} - -/// -/// Base class for Slice user exceptions. -/// -public abstract class UserException : Exception -{ - public virtual void iceWrite(OutputStream ostr) - { - ostr.startException(); - iceWriteImpl(ostr); - ostr.endException(); - } - - public virtual void iceRead(InputStream istr) + protected Exception(string? message, System.Exception? innerException = null) + : base(message, innerException) { - istr.startException(); - iceReadImpl(istr); - istr.endException(); } - - public virtual bool iceUsesClasses() => false; - - /// - /// Constructs an Ice user exception with an optional inner exception. - /// - /// The inner exception. - protected UserException(System.Exception? innerException = null) : base(innerException) { } - - protected abstract void iceWriteImpl(OutputStream ostr); - protected abstract void iceReadImpl(InputStream istr); } diff --git a/csharp/src/Ice/Internal/OutgoingAsync.cs b/csharp/src/Ice/Internal/OutgoingAsync.cs index a3c59ae1a57..d3bef0979fd 100644 --- a/csharp/src/Ice/Internal/OutgoingAsync.cs +++ b/csharp/src/Ice/Internal/OutgoingAsync.cs @@ -811,26 +811,26 @@ public override bool response() case ReplyStatus.UnknownLocalException: case ReplyStatus.UnknownUserException: { - string unknown = is_.readString(); + string message = is_.readString(); Ice.UnknownException ex = null; switch (replyStatus) { case ReplyStatus.UnknownException: { - ex = new Ice.UnknownException(); + ex = new UnknownException(message); break; } case ReplyStatus.UnknownLocalException: { - ex = new Ice.UnknownLocalException(); + ex = new UnknownLocalException(message); break; } case ReplyStatus.UnknownUserException: { - ex = new Ice.UnknownUserException(); + ex = new UnknownUserException(message); break; } @@ -840,8 +840,6 @@ public override bool response() break; } } - - ex.unknown = unknown; throw ex; } diff --git a/csharp/src/Ice/LocalException.cs b/csharp/src/Ice/LocalException.cs index 6ab7208a707..3d0d222591d 100644 --- a/csharp/src/Ice/LocalException.cs +++ b/csharp/src/Ice/LocalException.cs @@ -1,2034 +1,32 @@ // Copyright (c) ZeroC, Inc. -namespace Ice; - -/// -/// This exception is raised when a failure occurs during initialization. -/// -public class InitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public InitializationException() - { - _initDM(); - } - - public InitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public InitializationException(string reason) - { - _initDM(reason); - } - - public InitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::InitializationException"; - } -} - -/// -/// This exception indicates that a failure occurred while initializing a plug-in. -/// -public class PluginInitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public PluginInitializationException() - { - _initDM(); - } - - public PluginInitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public PluginInitializationException(string reason) - { - _initDM(reason); - } - - public PluginInitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::PluginInitializationException"; - } -} - -/// -/// An attempt was made to register something more than once with the Ice run time. -/// This exception is raised if an -/// attempt is made to register a servant, servant locator, facet, value factory, plug-in, object adapter, object, or -/// user exception factory more than once for the same ID. -/// -public class AlreadyRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public AlreadyRegisteredException() - { - _initDM(); - } - - public AlreadyRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } - - public AlreadyRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")] - public AlreadyRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } - - public override string ice_id() - { - return "::Ice::AlreadyRegisteredException"; - } -} - -/// -/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. -/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, -/// object adapter, object, or user exception factory that is not currently registered. It's also raised if the Ice -/// locator can't find an object or object adapter when resolving an indirect proxy or when an object adapter is -/// activated. -/// -public class NotRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public NotRegisteredException() - { - _initDM(); - } - - public NotRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } - - public NotRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } - - public NotRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } - public override string ice_id() - { - return "::Ice::NotRegisteredException"; - } -} - -/// -/// The operation can only be invoked with a twoway request. -/// This exception is raised if an attempt is made to invoke -/// an operation with ice_oneway, ice_batchOneway, ice_datagram, or -/// ice_batchDatagram and the operation has a return value, out-parameters, or an exception specification. -/// -public class TwowayOnlyException : LocalException -{ - public string operation; - - private void _initDM() - { - this.operation = ""; - } - - public TwowayOnlyException() - { - _initDM(); - } - - public TwowayOnlyException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string operation) - { - this.operation = operation; - } - - public TwowayOnlyException(string operation) - { - _initDM(operation); - } - - public TwowayOnlyException(string operation, System.Exception ex) : base(ex) - { - _initDM(operation); - } - - public override string ice_id() - { - return "::Ice::TwowayOnlyException"; - } -} - -/// -/// This exception is raised if an operation call on a server raises an unknown exception. -/// For example, for C++, this -/// exception is raised if the server throws a C++ exception that is not directly or indirectly derived from -/// Ice::LocalException or Ice::UserException. -/// -public class UnknownException : LocalException -{ - public string unknown; - private void _initDM() - { - this.unknown = ""; - } - - public UnknownException() - { - _initDM(); - } - - public UnknownException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string unknown) - { - this.unknown = unknown; - } - - public UnknownException(string unknown) - { - _initDM(unknown); - } - - public UnknownException(string unknown, System.Exception ex) : base(ex) - { - _initDM(unknown); - } - - public override string ice_id() - { - return "::Ice::UnknownException"; - } -} - -/// -/// This exception is raised if an operation call on a server raises a local exception. -/// Because local exceptions are -/// not transmitted by the Ice protocol, the client receives all local exceptions raised by the server as -/// UnknownLocalException. The only exception to this rule are all exceptions derived from -/// RequestFailedException, which are transmitted by the Ice protocol even though they are declared -/// local. -/// -public class UnknownLocalException : UnknownException -{ - public UnknownLocalException() - { - } - - public UnknownLocalException(System.Exception ex) : base(ex) - { - } - - public UnknownLocalException(string unknown) : base(unknown) - { - } - - public UnknownLocalException(string unknown, System.Exception ex) : base(unknown, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownLocalException"; - } -} - -/// -/// An operation raised an incorrect user exception. -/// This exception is raised if an operation raises a user exception -/// that is not declared in the exception's throws clause. Such undeclared exceptions are not transmitted -/// from the server to the client by the Ice protocol, but instead the client just gets an UnknownUserException. -/// This is necessary in order to not violate the contract established by an operation's signature: Only local -/// exceptions and user exceptions declared in the throws clause can be raised. -/// -public class UnknownUserException : UnknownException -{ - public UnknownUserException() - { - } - - public UnknownUserException(System.Exception ex) : base(ex) - { - } - - public UnknownUserException(string unknown) : base(unknown) - { - } - - public UnknownUserException(string unknown, System.Exception ex) : base(unknown, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownUserException"; - } -} - -/// -/// This exception is raised if the Communicator has been destroyed. -/// -public class CommunicatorDestroyedException : LocalException -{ - public CommunicatorDestroyedException() - { - } - - public CommunicatorDestroyedException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CommunicatorDestroyedException"; - } -} - -/// -/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. -/// -public class ObjectAdapterDeactivatedException : LocalException -{ - public string name; - - private void _initDM() - { - this.name = ""; - } - - public ObjectAdapterDeactivatedException() - { - _initDM(); - } - - public ObjectAdapterDeactivatedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string name) - { - this.name = name; - } - - public ObjectAdapterDeactivatedException(string name) - { - _initDM(name); - } - - public ObjectAdapterDeactivatedException(string name, System.Exception ex) : base(ex) - { - _initDM(name); - } - - public override string ice_id() - { - return "::Ice::ObjectAdapterDeactivatedException"; - } -} - -/// -/// This exception is raised if an ObjectAdapter cannot be activated. -/// This happens if the Locator -/// detects another active ObjectAdapter with the same adapter id. -/// -public class ObjectAdapterIdInUseException : LocalException -{ - public string id; - - private void _initDM() - { - this.id = ""; - } - - public ObjectAdapterIdInUseException() - { - _initDM(); - } - - public ObjectAdapterIdInUseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string id) - { - this.id = id; - } - - public ObjectAdapterIdInUseException(string id) - { - _initDM(id); - } - - public ObjectAdapterIdInUseException(string id, System.Exception ex) : base(ex) - { - _initDM(id); - } - - public override string ice_id() - { - return "::Ice::ObjectAdapterIdInUseException"; - } -} - -/// -/// This exception is raised if no suitable endpoint is available. -/// -public class NoEndpointException : LocalException -{ - public string proxy; - - private void _initDM() - { - this.proxy = ""; - } - - public NoEndpointException() - { - _initDM(); - } - - public NoEndpointException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string proxy) - { - this.proxy = proxy; - } - - public NoEndpointException(string proxy) - { - _initDM(proxy); - } - - public NoEndpointException(string proxy, System.Exception ex) : base(ex) - { - _initDM(proxy); - } - - public override string ice_id() - { - return "::Ice::NoEndpointException"; - } -} - -/// -/// This exception is raised if there was an error while parsing an endpoint. -/// -public class EndpointParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointParseException() - { - _initDM(); - } - - public EndpointParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointParseException(string str) - { - _initDM(str); - } - - public EndpointParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::EndpointParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing an endpoint selection type. -/// -public class EndpointSelectionTypeParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointSelectionTypeParseException() - { - _initDM(); - } - - public EndpointSelectionTypeParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointSelectionTypeParseException(string str) - { - _initDM(str); - } - - public EndpointSelectionTypeParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::EndpointSelectionTypeParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a version. -/// -public class VersionParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public VersionParseException() - { - _initDM(); - } - - public VersionParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public VersionParseException(string str) - { - _initDM(str); - } - - public VersionParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::VersionParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a stringified identity. -/// -public class IdentityParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public IdentityParseException() - { - _initDM(); - } - - public IdentityParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public IdentityParseException(string str) - { - _initDM(str); - } - - public IdentityParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::IdentityParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a stringified proxy. -/// -public class ProxyParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public ProxyParseException() - { - _initDM(); - } - - public ProxyParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public ProxyParseException(string str) - { - _initDM(str); - } - - public ProxyParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::ProxyParseException"; - } -} - -/// -/// This exception is raised if an illegal identity is encountered. -/// -public class IllegalIdentityException : LocalException -{ - public Identity id; - - private void _initDM() - { - this.id = new Identity(); - } - - public IllegalIdentityException() - { - _initDM(); - } - - public IllegalIdentityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(Identity id) - { - this.id = id; - } - - public IllegalIdentityException(Identity id) - { - _initDM(id); - } - - public IllegalIdentityException(Identity id, System.Exception ex) : base(ex) - { - _initDM(id); - } - - public override string ice_id() - { - return "::Ice::IllegalIdentityException"; - } -} - -/// -/// This exception is raised to reject an illegal servant (typically a null servant). -/// -public class IllegalServantException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public IllegalServantException() - { - _initDM(); - } - - public IllegalServantException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public IllegalServantException(string reason) - { - _initDM(reason); - } - - public IllegalServantException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::IllegalServantException"; - } -} - -/// -/// This exception is raised if a request failed. -/// This exception, and all exceptions derived from -/// RequestFailedException, are transmitted by the Ice protocol, even though they are declared -/// local. -/// -public class RequestFailedException : LocalException -{ - public Identity id; - public string facet; - public string operation; - - private void _initDM() - { - this.id = new Identity(); - this.facet = ""; - this.operation = ""; - } - - public RequestFailedException() - { - _initDM(); - } - - public RequestFailedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(Identity id, string facet, string operation) - { - this.id = id; - this.facet = facet; - this.operation = operation; - } - - public RequestFailedException(Identity id, string facet, string operation) - { - _initDM(id, facet, operation); - } - - public RequestFailedException(Identity id, string facet, string operation, System.Exception ex) : base(ex) - { - _initDM(id, facet, operation); - } - - public override string ice_id() - { - return "::Ice::RequestFailedException"; - } -} - -/// -/// This exception is raised if an object does not exist on the server, that is, if no facets with the given identity -/// exist. -/// -public class ObjectNotExistException : RequestFailedException -{ - public ObjectNotExistException() - { - } - - public ObjectNotExistException(System.Exception ex) : base(ex) - { - } - - public ObjectNotExistException(Identity id, string facet, string operation) : base(id, facet, operation) - { - } - - public ObjectNotExistException(Identity id, string facet, string operation, System.Exception ex) - : base(id, facet, operation, ex) - { - } - - public override string ice_id() - { - return "::Ice::ObjectNotExistException"; - } -} - -/// -/// This exception is raised if no facet with the given name exists, but at least one facet with the given identity -/// exists. -/// -public class FacetNotExistException : RequestFailedException -{ - public FacetNotExistException() - { - } - - public FacetNotExistException(System.Exception ex) : base(ex) - { - } - - public FacetNotExistException(Identity id, string facet, string operation) : base(id, facet, operation) - { - } - - public FacetNotExistException(Identity id, string facet, string operation, System.Exception ex) - : base(id, facet, operation, ex) - { - } - - public override string ice_id() - { - return "::Ice::FacetNotExistException"; - } -} - -/// -/// This exception is raised if an operation for a given object does not exist on the server. -/// Typically this is caused -/// by either the client or the server using an outdated Slice specification. -/// -public class OperationNotExistException : RequestFailedException -{ - public OperationNotExistException() - { - } - - public OperationNotExistException(System.Exception ex) : base(ex) - { - } - - public OperationNotExistException(Identity id, string facet, string operation) : base(id, facet, operation) - { - } - - public OperationNotExistException(Identity id, string facet, string operation, System.Exception ex) - : base(id, facet, operation, ex) - { - } - - public override string ice_id() - { - return "::Ice::OperationNotExistException"; - } -} - -/// -/// This exception is raised if a system error occurred in the server or client process. -/// There are many possible causes -/// for such a system exception. For details on the cause, SyscallException.error should be inspected. -/// -public class SyscallException : LocalException -{ - public int error; - - private void _initDM() - { - this.error = 0; - } - - public SyscallException() - { - _initDM(); - } - - public SyscallException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error) - { - this.error = error; - } - - public SyscallException(int error) - { - _initDM(error); - } - - public SyscallException(int error, System.Exception ex) : base(ex) - { - _initDM(error); - } - - public override string ice_id() - { - return "::Ice::SyscallException"; - } -} - -/// -/// This exception indicates socket errors. -/// -public class SocketException : SyscallException -{ - public SocketException() - { - } - - public SocketException(System.Exception ex) : base(ex) - { - } - - public SocketException(int error) : base(error) - { - } - - public SocketException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::SocketException"; - } -} - -/// This exception indicates file errors. -public class FileException : SyscallException -{ - public string path; - - private void _initDM() - { - this.path = ""; - } - - public FileException() - { - _initDM(); - } - - public FileException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string path) - { - this.path = path; - } - - public FileException(int error, string path) : base(error) - { - _initDM(path); - } - - public FileException(int error, string path, System.Exception ex) : base(error, ex) - { - _initDM(path); - } - - public override string ice_id() - { - return "::Ice::FileException"; - } -} - -/// -/// This exception indicates connection failures. -/// -public class ConnectFailedException : SocketException -{ - public ConnectFailedException() - { - } - - public ConnectFailedException(System.Exception ex) : base(ex) - { - } - - public ConnectFailedException(int error) : base(error) - { - } - - public ConnectFailedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectFailedException"; - } -} - -/// -/// This exception indicates a connection failure for which the server host actively refuses a connection. -/// -public class ConnectionRefusedException : ConnectFailedException -{ - public ConnectionRefusedException() - { - } - - public ConnectionRefusedException(System.Exception ex) : base(ex) - { - } - - public ConnectionRefusedException(int error) : base(error) - { - } - - public ConnectionRefusedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionRefusedException"; - } -} - -/// -/// This exception indicates a lost connection. -/// -public class ConnectionLostException : SocketException -{ - public ConnectionLostException() - { - } - - public ConnectionLostException(System.Exception ex) : base(ex) - { - } - - public ConnectionLostException(int error) : base(error) - { - } - - public ConnectionLostException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionLostException"; - } -} - -/// -/// This exception indicates a DNS problem. -/// For details on the cause, DNSException.error should be inspected. -/// -public class DNSException : LocalException -{ - public int error; - public string host; - - private void _initDM() - { - this.error = 0; - this.host = ""; - } - - public DNSException() - { - _initDM(); - } - - public DNSException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error, string host) - { - this.error = error; - this.host = host; - } - - public DNSException(int error, string host) - { - _initDM(error, host); - } - - public DNSException(int error, string host, System.Exception ex) : base(ex) - { - _initDM(error, host); - } - - public override string ice_id() - { - return "::Ice::DNSException"; - } -} - -/// -/// This exception indicates that a connection was closed gracefully. -/// -public class ConnectionClosedException : LocalException -{ - public ConnectionClosedException() - { - } - - public override string ice_id() => "::Ice::ConnectionClosedException"; -} - -/// -/// This exception indicates that a connection was aborted by the idle check. -/// -public class ConnectionIdleException : LocalException -{ - public ConnectionIdleException() - { - } - - public override string ice_id() => "::Ice::ConnectionIdleException"; -} - -/// This exception indicates a timeout condition. -public class TimeoutException : LocalException -{ - public TimeoutException() - { - } - - public TimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::TimeoutException"; - } -} - -/// -/// This exception indicates a connection establishment timeout condition. -/// -public class ConnectTimeoutException : TimeoutException -{ - public ConnectTimeoutException() - { - } - - public ConnectTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectTimeoutException"; - } -} - -/// This exception indicates a connection closure timeout condition. -public class CloseTimeoutException : TimeoutException -{ - public CloseTimeoutException() - { - } - - public CloseTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseTimeoutException"; - } -} - -/// -/// This exception indicates that an invocation failed because it timed out. -/// -public class InvocationTimeoutException : TimeoutException -{ - public InvocationTimeoutException() - { - } - - public InvocationTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationTimeoutException"; - } -} - -/// -/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. -/// -public class InvocationCanceledException : LocalException -{ - public InvocationCanceledException() - { - } - - public InvocationCanceledException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationCanceledException"; - } -} - -/// -/// A generic exception base for all kinds of protocol error conditions. -/// -public class ProtocolException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public ProtocolException() - { - _initDM(); - } - - public ProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public ProtocolException(string reason) - { - _initDM(reason); - } - - public ProtocolException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::ProtocolException"; - } -} - -/// -/// This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). -/// -public class BadMagicException : ProtocolException -{ - public byte[] badMagic; - - public BadMagicException() - { - } - - public BadMagicException(System.Exception ex) : base(ex) - { - } - - private void _initDM(byte[] badMagic) - { - this.badMagic = badMagic; - } - - public BadMagicException(string reason, byte[] badMagic) : base(reason) - { - _initDM(badMagic); - } - - public BadMagicException(string reason, byte[] badMagic, System.Exception ex) : base(reason, ex) - { - _initDM(badMagic); - } - - public override string ice_id() - { - return "::Ice::BadMagicException"; - } -} - -/// -/// This exception indicates an unsupported protocol version. -/// -public class UnsupportedProtocolException : ProtocolException -{ - public ProtocolVersion bad; - public ProtocolVersion supported; - - private void _initDM() - { - this.bad = new ProtocolVersion(); - this.supported = new ProtocolVersion(); - } - - public UnsupportedProtocolException() - { - _initDM(); - } - - public UnsupportedProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(ProtocolVersion bad, ProtocolVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - - public override string ice_id() - { - return "::Ice::UnsupportedProtocolException"; - } -} - -/// -/// This exception indicates an unsupported data encoding version. -/// -public class UnsupportedEncodingException : ProtocolException -{ - public EncodingVersion bad; - public EncodingVersion supported; - - private void _initDM() - { - this.bad = new EncodingVersion(); - this.supported = new EncodingVersion(); - } - - public UnsupportedEncodingException() - { - _initDM(); - } - - public UnsupportedEncodingException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(EncodingVersion bad, EncodingVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - public override string ice_id() - { - return "::Ice::UnsupportedEncodingException"; - } -} - -/// -/// This exception indicates that an unknown protocol message has been received. -/// -public class UnknownMessageException : ProtocolException -{ - public UnknownMessageException() - { - } - - public UnknownMessageException(System.Exception ex) : base(ex) - { - } - - public UnknownMessageException(string reason) : base(reason) - { - } - - public UnknownMessageException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownMessageException"; - } -} - -/// -/// This exception is raised if a message is received over a connection that is not yet validated. -/// -public class ConnectionNotValidatedException : ProtocolException -{ - public ConnectionNotValidatedException() - { - } - - public ConnectionNotValidatedException(System.Exception ex) : base(ex) - { - } - - public ConnectionNotValidatedException(string reason) : base(reason) - { - } - - public ConnectionNotValidatedException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionNotValidatedException"; - } -} - -/// -/// This exception indicates that an unknown reply status has been received. -/// -public class UnknownReplyStatusException : ProtocolException -{ - public UnknownReplyStatusException() - { - } - - public UnknownReplyStatusException(System.Exception ex) : base(ex) - { - } - - public UnknownReplyStatusException(string reason) : base(reason) - { - } - - public UnknownReplyStatusException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownReplyStatusException"; - } -} - -/// -/// This exception indicates that the connection has been gracefully shut down by the server. -/// The operation call that -/// caused this exception has not been executed by the server. In most cases you will not get this exception, because -/// the client will automatically retry the operation call in case the server shut down the connection. However, if -/// upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is -/// propagated to the application code. -/// -public class CloseConnectionException : ProtocolException -{ - public CloseConnectionException() - { - } - - public CloseConnectionException(System.Exception ex) : base(ex) - { - } - - public CloseConnectionException(string reason) : base(reason) - { - } - - public CloseConnectionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseConnectionException"; - } -} - -/// -/// This exception is raised by an operation call if the application closes the connection locally using -/// Connection.close. -/// -public class ConnectionManuallyClosedException : LocalException -{ - public bool graceful; - - private void _initDM() - { - } - - public ConnectionManuallyClosedException() - { - _initDM(); - } - - public ConnectionManuallyClosedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(bool graceful) - { - this.graceful = graceful; - } - - public ConnectionManuallyClosedException(bool graceful) - { - _initDM(graceful); - } - - public ConnectionManuallyClosedException(bool graceful, System.Exception ex) : base(ex) - { - _initDM(graceful); - } - - public override string ice_id() - { - return "::Ice::ConnectionManuallyClosedException"; - } -} - -/// -/// This exception indicates that a message size is less than the minimum required size. -/// -public class IllegalMessageSizeException : ProtocolException -{ - public IllegalMessageSizeException() - { - } - - public IllegalMessageSizeException(System.Exception ex) : base(ex) - { - } - - public IllegalMessageSizeException(string reason) : base(reason) - { - } - - public IllegalMessageSizeException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::IllegalMessageSizeException"; - } -} - -/// -/// This exception indicates a problem with compressing or uncompressing data. -/// -public class CompressionException : ProtocolException -{ - public CompressionException() - { - } - - public CompressionException(System.Exception ex) : base(ex) - { - } - - public CompressionException(string reason) : base(reason) - { - } - - public CompressionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CompressionException"; - } -} - -/// -/// A datagram exceeds the configured size. -/// This exception is raised if a datagram exceeds the configured send or -/// receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). -/// -public class DatagramLimitException : ProtocolException -{ - public DatagramLimitException() - { - } - - public DatagramLimitException(System.Exception ex) : base(ex) - { - } - - public DatagramLimitException(string reason) : base(reason) - { - } - - public DatagramLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - public override string ice_id() - { - return "::Ice::DatagramLimitException"; - } -} - -/// -/// This exception is raised for errors during marshaling or unmarshaling data. -/// -public class MarshalException : ProtocolException -{ - public MarshalException() - { - } - - public MarshalException(System.Exception ex) : base(ex) - { - } - - public MarshalException(string reason) : base(reason) - { - } - - public MarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MarshalException"; - } -} - -/// -/// This exception is raised if inconsistent data is received while unmarshaling a proxy. -/// -public class ProxyUnmarshalException : MarshalException -{ - public ProxyUnmarshalException() - { - } - - public ProxyUnmarshalException(System.Exception ex) : base(ex) - { - } - - public ProxyUnmarshalException(string reason) : base(reason) - { - } - - public ProxyUnmarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ProxyUnmarshalException"; - } -} - -/// -/// This exception is raised if an out-of-bounds condition occurs during unmarshaling. -/// -public class UnmarshalOutOfBoundsException : MarshalException -{ - public UnmarshalOutOfBoundsException() - { - } - - public UnmarshalOutOfBoundsException(System.Exception ex) : base(ex) - { - } - - public UnmarshalOutOfBoundsException(string reason) : base(reason) - { - } - - public UnmarshalOutOfBoundsException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnmarshalOutOfBoundsException"; - } -} - -/// -/// This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. -/// -public class NoValueFactoryException : MarshalException -{ - public string type; - - private void _initDM() - { - this.type = ""; - } - - public NoValueFactoryException() - { - _initDM(); - } - - public NoValueFactoryException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type) - { - this.type = type; - } +#nullable enable - public NoValueFactoryException(string reason, string type) : base(reason) - { - _initDM(type); - } - - public NoValueFactoryException(string reason, string type, System.Exception ex) : base(reason, ex) - { - _initDM(type); - } - - public override string ice_id() - { - return "::Ice::NoValueFactoryException"; - } -} - -/// -/// This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. -/// This -/// can happen if client and server are compiled with mismatched Slice definitions or if a class of the wrong type is -/// passed as a parameter or return value using dynamic invocation. This exception can also be raised if IceStorm is -/// used to send Slice class instances and an operation is subscribed to the wrong topic. -/// -public class UnexpectedObjectException : MarshalException -{ - public string type; - public string expectedType; - - private void _initDM() - { - this.type = ""; - this.expectedType = ""; - } - - public UnexpectedObjectException() - { - _initDM(); - } - - public UnexpectedObjectException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type, string expectedType) - { - this.type = type; - this.expectedType = expectedType; - } - - public UnexpectedObjectException(string reason, string type, string expectedType) : base(reason) - { - _initDM(type, expectedType); - } - - public UnexpectedObjectException(string reason, string type, string expectedType, System.Exception ex) : base(reason, ex) - { - _initDM(type, expectedType); - } - - public override string ice_id() - { - return "::Ice::UnexpectedObjectException"; - } -} - -/// -/// This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the -/// Ice.MessageSizeMax property. -/// -public class MemoryLimitException : MarshalException -{ - public MemoryLimitException() - { - } - - public MemoryLimitException(System.Exception ex) : base(ex) - { - } - - public MemoryLimitException(string reason) : base(reason) - { - } - - public MemoryLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MemoryLimitException"; - } -} - -/// -/// This exception indicates a malformed data encapsulation. -/// -public class EncapsulationException : MarshalException -{ - public EncapsulationException() - { - } - - public EncapsulationException(System.Exception ex) : base(ex) - { - } - - public EncapsulationException(string reason) : base(reason) - { - } - - public EncapsulationException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::EncapsulationException"; - } -} - -/// -/// This exception is raised if an unsupported feature is used. -/// The unsupported feature string contains the name of the -/// unsupported feature. -/// -public class FeatureNotSupportedException : LocalException -{ - public string unsupportedFeature; - - private void _initDM() - { - this.unsupportedFeature = ""; - } - - public FeatureNotSupportedException() - { - _initDM(); - } - - public FeatureNotSupportedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string unsupportedFeature) - { - this.unsupportedFeature = unsupportedFeature; - } - - public FeatureNotSupportedException(string unsupportedFeature) - { - _initDM(unsupportedFeature); - } - - public FeatureNotSupportedException(string unsupportedFeature, System.Exception ex) : base(ex) - { - _initDM(unsupportedFeature); - } - - public override string ice_id() - { - return "::Ice::FeatureNotSupportedException"; - } -} - -/// -/// This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. -/// -public class SecurityException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public SecurityException() - { - _initDM(); - } - - public SecurityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public SecurityException(string reason) - { - _initDM(reason); - } - - public SecurityException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::SecurityException"; - } -} +namespace Ice; /// -/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. +/// Base class for Ice run-time exceptions. /// -public class FixedProxyException : LocalException +public class LocalException : Exception { - public FixedProxyException() + /// + /// Constructs a LocalException. + /// + /// The exception message. + /// The inner exception. + public LocalException(string? message = null, System.Exception? innerException = null) + : base(message, innerException) { } - public FixedProxyException(System.Exception ex) : base(ex) + /// + /// Constructs a LocalException. + /// + /// The inner exception. + public LocalException(System.Exception innerException) + : this(message: null, innerException) { } - public override string ice_id() - { - return "::Ice::FixedProxyException"; - } + public override string ice_id() => "::Ice::LocalException"; } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs new file mode 100644 index 00000000000..9952ddb356f --- /dev/null +++ b/csharp/src/Ice/LocalExceptions.cs @@ -0,0 +1,1785 @@ +// Copyright (c) ZeroC, Inc. + +namespace Ice; + +/// +/// This exception is raised when a failure occurs during initialization. +/// +public class InitializationException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public InitializationException() + { + _initDM(); + } + + public InitializationException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public InitializationException(string reason) + { + _initDM(reason); + } + + public InitializationException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::InitializationException"; + } +} + +/// +/// This exception indicates that a failure occurred while initializing a plug-in. +/// +public class PluginInitializationException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public PluginInitializationException() + { + _initDM(); + } + + public PluginInitializationException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public PluginInitializationException(string reason) + { + _initDM(reason); + } + + public PluginInitializationException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::PluginInitializationException"; + } +} + +/// +/// An attempt was made to register something more than once with the Ice run time. +/// This exception is raised if an +/// attempt is made to register a servant, servant locator, facet, value factory, plug-in, object adapter, object, or +/// user exception factory more than once for the same ID. +/// +public class AlreadyRegisteredException : LocalException +{ + public string kindOfObject; + public string id; + + private void _initDM() + { + this.kindOfObject = ""; + this.id = ""; + } + + public AlreadyRegisteredException() + { + _initDM(); + } + + public AlreadyRegisteredException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string kindOfObject, string id) + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public AlreadyRegisteredException(string kindOfObject, string id) + { + _initDM(kindOfObject, id); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")] + public AlreadyRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) + { + _initDM(kindOfObject, id); + } + + public override string ice_id() + { + return "::Ice::AlreadyRegisteredException"; + } +} + +/// +/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. +/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, +/// object adapter, object, or user exception factory that is not currently registered. It's also raised if the Ice +/// locator can't find an object or object adapter when resolving an indirect proxy or when an object adapter is +/// activated. +/// +public class NotRegisteredException : LocalException +{ + public string kindOfObject; + public string id; + + private void _initDM() + { + this.kindOfObject = ""; + this.id = ""; + } + + public NotRegisteredException() + { + _initDM(); + } + + public NotRegisteredException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string kindOfObject, string id) + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public NotRegisteredException(string kindOfObject, string id) + { + _initDM(kindOfObject, id); + } + + public NotRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) + { + _initDM(kindOfObject, id); + } + public override string ice_id() + { + return "::Ice::NotRegisteredException"; + } +} + +/// +/// The operation can only be invoked with a twoway request. +/// This exception is raised if an attempt is made to invoke +/// an operation with ice_oneway, ice_batchOneway, ice_datagram, or +/// ice_batchDatagram and the operation has a return value, out-parameters, or an exception specification. +/// +public class TwowayOnlyException : LocalException +{ + public string operation; + + private void _initDM() + { + this.operation = ""; + } + + public TwowayOnlyException() + { + _initDM(); + } + + public TwowayOnlyException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string operation) + { + this.operation = operation; + } + + public TwowayOnlyException(string operation) + { + _initDM(operation); + } + + public TwowayOnlyException(string operation, System.Exception ex) : base(ex) + { + _initDM(operation); + } + + public override string ice_id() + { + return "::Ice::TwowayOnlyException"; + } +} + +/// +/// This exception is raised if the Communicator has been destroyed. +/// +public class CommunicatorDestroyedException : LocalException +{ + public CommunicatorDestroyedException() + { + } + + public CommunicatorDestroyedException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::CommunicatorDestroyedException"; + } +} + +/// +/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. +/// +public class ObjectAdapterDeactivatedException : LocalException +{ + public string name; + + private void _initDM() + { + this.name = ""; + } + + public ObjectAdapterDeactivatedException() + { + _initDM(); + } + + public ObjectAdapterDeactivatedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string name) + { + this.name = name; + } + + public ObjectAdapterDeactivatedException(string name) + { + _initDM(name); + } + + public ObjectAdapterDeactivatedException(string name, System.Exception ex) : base(ex) + { + _initDM(name); + } + + public override string ice_id() + { + return "::Ice::ObjectAdapterDeactivatedException"; + } +} + +/// +/// This exception is raised if an ObjectAdapter cannot be activated. +/// This happens if the Locator +/// detects another active ObjectAdapter with the same adapter id. +/// +public class ObjectAdapterIdInUseException : LocalException +{ + public string id; + + private void _initDM() + { + this.id = ""; + } + + public ObjectAdapterIdInUseException() + { + _initDM(); + } + + public ObjectAdapterIdInUseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string id) + { + this.id = id; + } + + public ObjectAdapterIdInUseException(string id) + { + _initDM(id); + } + + public ObjectAdapterIdInUseException(string id, System.Exception ex) : base(ex) + { + _initDM(id); + } + + public override string ice_id() + { + return "::Ice::ObjectAdapterIdInUseException"; + } +} + +/// +/// This exception is raised if no suitable endpoint is available. +/// +public class NoEndpointException : LocalException +{ + public string proxy; + + private void _initDM() + { + this.proxy = ""; + } + + public NoEndpointException() + { + _initDM(); + } + + public NoEndpointException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string proxy) + { + this.proxy = proxy; + } + + public NoEndpointException(string proxy) + { + _initDM(proxy); + } + + public NoEndpointException(string proxy, System.Exception ex) : base(ex) + { + _initDM(proxy); + } + + public override string ice_id() + { + return "::Ice::NoEndpointException"; + } +} + +/// +/// This exception is raised if there was an error while parsing an endpoint. +/// +public class EndpointParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public EndpointParseException() + { + _initDM(); + } + + public EndpointParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public EndpointParseException(string str) + { + _initDM(str); + } + + public EndpointParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::EndpointParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing an endpoint selection type. +/// +public class EndpointSelectionTypeParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public EndpointSelectionTypeParseException() + { + _initDM(); + } + + public EndpointSelectionTypeParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public EndpointSelectionTypeParseException(string str) + { + _initDM(str); + } + + public EndpointSelectionTypeParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::EndpointSelectionTypeParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a version. +/// +public class VersionParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public VersionParseException() + { + _initDM(); + } + + public VersionParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public VersionParseException(string str) + { + _initDM(str); + } + + public VersionParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::VersionParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a stringified identity. +/// +public class IdentityParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public IdentityParseException() + { + _initDM(); + } + + public IdentityParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public IdentityParseException(string str) + { + _initDM(str); + } + + public IdentityParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::IdentityParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a stringified proxy. +/// +public class ProxyParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public ProxyParseException() + { + _initDM(); + } + + public ProxyParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public ProxyParseException(string str) + { + _initDM(str); + } + + public ProxyParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::ProxyParseException"; + } +} + +/// +/// This exception is raised if an illegal identity is encountered. +/// +public class IllegalIdentityException : LocalException +{ + public Identity id; + + private void _initDM() + { + this.id = new Identity(); + } + + public IllegalIdentityException() + { + _initDM(); + } + + public IllegalIdentityException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(Identity id) + { + this.id = id; + } + + public IllegalIdentityException(Identity id) + { + _initDM(id); + } + + public IllegalIdentityException(Identity id, System.Exception ex) : base(ex) + { + _initDM(id); + } + + public override string ice_id() + { + return "::Ice::IllegalIdentityException"; + } +} + +/// +/// This exception is raised to reject an illegal servant (typically a null servant). +/// +public class IllegalServantException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public IllegalServantException() + { + _initDM(); + } + + public IllegalServantException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public IllegalServantException(string reason) + { + _initDM(reason); + } + + public IllegalServantException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::IllegalServantException"; + } +} + +/// +/// This exception is raised if a system error occurred in the server or client process. +/// There are many possible causes +/// for such a system exception. For details on the cause, SyscallException.error should be inspected. +/// +public class SyscallException : LocalException +{ + public int error; + + private void _initDM() + { + this.error = 0; + } + + public SyscallException() + { + _initDM(); + } + + public SyscallException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(int error) + { + this.error = error; + } + + public SyscallException(int error) + { + _initDM(error); + } + + public SyscallException(int error, System.Exception ex) : base(ex) + { + _initDM(error); + } + + public override string ice_id() + { + return "::Ice::SyscallException"; + } +} + +/// +/// This exception indicates socket errors. +/// +public class SocketException : SyscallException +{ + public SocketException() + { + } + + public SocketException(System.Exception ex) : base(ex) + { + } + + public SocketException(int error) : base(error) + { + } + + public SocketException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::SocketException"; + } +} + +/// This exception indicates file errors. +public class FileException : SyscallException +{ + public string path; + + private void _initDM() + { + this.path = ""; + } + + public FileException() + { + _initDM(); + } + + public FileException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string path) + { + this.path = path; + } + + public FileException(int error, string path) : base(error) + { + _initDM(path); + } + + public FileException(int error, string path, System.Exception ex) : base(error, ex) + { + _initDM(path); + } + + public override string ice_id() + { + return "::Ice::FileException"; + } +} + +/// +/// This exception indicates connection failures. +/// +public class ConnectFailedException : SocketException +{ + public ConnectFailedException() + { + } + + public ConnectFailedException(System.Exception ex) : base(ex) + { + } + + public ConnectFailedException(int error) : base(error) + { + } + + public ConnectFailedException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectFailedException"; + } +} + +/// +/// This exception indicates a connection failure for which the server host actively refuses a connection. +/// +public class ConnectionRefusedException : ConnectFailedException +{ + public ConnectionRefusedException() + { + } + + public ConnectionRefusedException(System.Exception ex) : base(ex) + { + } + + public ConnectionRefusedException(int error) : base(error) + { + } + + public ConnectionRefusedException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionRefusedException"; + } +} + +/// +/// This exception indicates a lost connection. +/// +public class ConnectionLostException : SocketException +{ + public ConnectionLostException() + { + } + + public ConnectionLostException(System.Exception ex) : base(ex) + { + } + + public ConnectionLostException(int error) : base(error) + { + } + + public ConnectionLostException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionLostException"; + } +} + +/// +/// This exception indicates a DNS problem. +/// For details on the cause, DNSException.error should be inspected. +/// +public class DNSException : LocalException +{ + public int error; + public string host; + + private void _initDM() + { + this.error = 0; + this.host = ""; + } + + public DNSException() + { + _initDM(); + } + + public DNSException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(int error, string host) + { + this.error = error; + this.host = host; + } + + public DNSException(int error, string host) + { + _initDM(error, host); + } + + public DNSException(int error, string host, System.Exception ex) : base(ex) + { + _initDM(error, host); + } + + public override string ice_id() + { + return "::Ice::DNSException"; + } +} + +/// +/// This exception indicates that a connection was closed gracefully. +/// +public class ConnectionClosedException : LocalException +{ + public ConnectionClosedException() + { + } + + public override string ice_id() => "::Ice::ConnectionClosedException"; +} + +/// +/// This exception indicates that a connection was aborted by the idle check. +/// +public class ConnectionIdleException : LocalException +{ + public ConnectionIdleException() + { + } + + public override string ice_id() => "::Ice::ConnectionIdleException"; +} + +/// This exception indicates a timeout condition. +public class TimeoutException : LocalException +{ + public TimeoutException() + { + } + + public TimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::TimeoutException"; + } +} + +/// +/// This exception indicates a connection establishment timeout condition. +/// +public class ConnectTimeoutException : TimeoutException +{ + public ConnectTimeoutException() + { + } + + public ConnectTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectTimeoutException"; + } +} + +/// This exception indicates a connection closure timeout condition. +public class CloseTimeoutException : TimeoutException +{ + public CloseTimeoutException() + { + } + + public CloseTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::CloseTimeoutException"; + } +} + +/// +/// This exception indicates that an invocation failed because it timed out. +/// +public class InvocationTimeoutException : TimeoutException +{ + public InvocationTimeoutException() + { + } + + public InvocationTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::InvocationTimeoutException"; + } +} + +/// +/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. +/// +public class InvocationCanceledException : LocalException +{ + public InvocationCanceledException() + { + } + + public InvocationCanceledException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::InvocationCanceledException"; + } +} + +/// +/// A generic exception base for all kinds of protocol error conditions. +/// +public class ProtocolException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public ProtocolException() + { + _initDM(); + } + + public ProtocolException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public ProtocolException(string reason) + { + _initDM(reason); + } + + public ProtocolException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::ProtocolException"; + } +} + +/// +/// This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). +/// +public class BadMagicException : ProtocolException +{ + public byte[] badMagic; + + public BadMagicException() + { + } + + public BadMagicException(System.Exception ex) : base(ex) + { + } + + private void _initDM(byte[] badMagic) + { + this.badMagic = badMagic; + } + + public BadMagicException(string reason, byte[] badMagic) : base(reason) + { + _initDM(badMagic); + } + + public BadMagicException(string reason, byte[] badMagic, System.Exception ex) : base(reason, ex) + { + _initDM(badMagic); + } + + public override string ice_id() + { + return "::Ice::BadMagicException"; + } +} + +/// +/// This exception indicates an unsupported protocol version. +/// +public class UnsupportedProtocolException : ProtocolException +{ + public ProtocolVersion bad; + public ProtocolVersion supported; + + private void _initDM() + { + this.bad = new ProtocolVersion(); + this.supported = new ProtocolVersion(); + } + + public UnsupportedProtocolException() + { + _initDM(); + } + + public UnsupportedProtocolException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(ProtocolVersion bad, ProtocolVersion supported) + { + this.bad = bad; + this.supported = supported; + } + + public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported) : base(reason) + { + _initDM(bad, supported); + } + + public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported, System.Exception ex) : base(reason, ex) + { + _initDM(bad, supported); + } + + public override string ice_id() + { + return "::Ice::UnsupportedProtocolException"; + } +} + +/// +/// This exception indicates an unsupported data encoding version. +/// +public class UnsupportedEncodingException : ProtocolException +{ + public EncodingVersion bad; + public EncodingVersion supported; + + private void _initDM() + { + this.bad = new EncodingVersion(); + this.supported = new EncodingVersion(); + } + + public UnsupportedEncodingException() + { + _initDM(); + } + + public UnsupportedEncodingException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(EncodingVersion bad, EncodingVersion supported) + { + this.bad = bad; + this.supported = supported; + } + + public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported) : base(reason) + { + _initDM(bad, supported); + } + + public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported, System.Exception ex) : base(reason, ex) + { + _initDM(bad, supported); + } + public override string ice_id() + { + return "::Ice::UnsupportedEncodingException"; + } +} + +/// +/// This exception indicates that an unknown protocol message has been received. +/// +public class UnknownMessageException : ProtocolException +{ + public UnknownMessageException() + { + } + + public UnknownMessageException(System.Exception ex) : base(ex) + { + } + + public UnknownMessageException(string reason) : base(reason) + { + } + + public UnknownMessageException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnknownMessageException"; + } +} + +/// +/// This exception is raised if a message is received over a connection that is not yet validated. +/// +public class ConnectionNotValidatedException : ProtocolException +{ + public ConnectionNotValidatedException() + { + } + + public ConnectionNotValidatedException(System.Exception ex) : base(ex) + { + } + + public ConnectionNotValidatedException(string reason) : base(reason) + { + } + + public ConnectionNotValidatedException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionNotValidatedException"; + } +} + +/// +/// This exception indicates that an unknown reply status has been received. +/// +public class UnknownReplyStatusException : ProtocolException +{ + public UnknownReplyStatusException() + { + } + + public UnknownReplyStatusException(System.Exception ex) : base(ex) + { + } + + public UnknownReplyStatusException(string reason) : base(reason) + { + } + + public UnknownReplyStatusException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnknownReplyStatusException"; + } +} + +/// +/// This exception indicates that the connection has been gracefully shut down by the server. +/// The operation call that +/// caused this exception has not been executed by the server. In most cases you will not get this exception, because +/// the client will automatically retry the operation call in case the server shut down the connection. However, if +/// upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is +/// propagated to the application code. +/// +public class CloseConnectionException : ProtocolException +{ + public CloseConnectionException() + { + } + + public CloseConnectionException(System.Exception ex) : base(ex) + { + } + + public CloseConnectionException(string reason) : base(reason) + { + } + + public CloseConnectionException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::CloseConnectionException"; + } +} + +/// +/// This exception is raised by an operation call if the application closes the connection locally using +/// Connection.close. +/// +public class ConnectionManuallyClosedException : LocalException +{ + public bool graceful; + + private void _initDM() + { + } + + public ConnectionManuallyClosedException() + { + _initDM(); + } + + public ConnectionManuallyClosedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(bool graceful) + { + this.graceful = graceful; + } + + public ConnectionManuallyClosedException(bool graceful) + { + _initDM(graceful); + } + + public ConnectionManuallyClosedException(bool graceful, System.Exception ex) : base(ex) + { + _initDM(graceful); + } + + public override string ice_id() + { + return "::Ice::ConnectionManuallyClosedException"; + } +} + +/// +/// This exception indicates that a message size is less than the minimum required size. +/// +public class IllegalMessageSizeException : ProtocolException +{ + public IllegalMessageSizeException() + { + } + + public IllegalMessageSizeException(System.Exception ex) : base(ex) + { + } + + public IllegalMessageSizeException(string reason) : base(reason) + { + } + + public IllegalMessageSizeException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::IllegalMessageSizeException"; + } +} + +/// +/// This exception indicates a problem with compressing or uncompressing data. +/// +public class CompressionException : ProtocolException +{ + public CompressionException() + { + } + + public CompressionException(System.Exception ex) : base(ex) + { + } + + public CompressionException(string reason) : base(reason) + { + } + + public CompressionException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::CompressionException"; + } +} + +/// +/// A datagram exceeds the configured size. +/// This exception is raised if a datagram exceeds the configured send or +/// receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). +/// +public class DatagramLimitException : ProtocolException +{ + public DatagramLimitException() + { + } + + public DatagramLimitException(System.Exception ex) : base(ex) + { + } + + public DatagramLimitException(string reason) : base(reason) + { + } + + public DatagramLimitException(string reason, System.Exception ex) : base(reason, ex) + { + } + public override string ice_id() + { + return "::Ice::DatagramLimitException"; + } +} + +/// +/// This exception is raised for errors during marshaling or unmarshaling data. +/// +public class MarshalException : ProtocolException +{ + public MarshalException() + { + } + + public MarshalException(System.Exception ex) : base(ex) + { + } + + public MarshalException(string reason) : base(reason) + { + } + + public MarshalException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::MarshalException"; + } +} + +/// +/// This exception is raised if inconsistent data is received while unmarshaling a proxy. +/// +public class ProxyUnmarshalException : MarshalException +{ + public ProxyUnmarshalException() + { + } + + public ProxyUnmarshalException(System.Exception ex) : base(ex) + { + } + + public ProxyUnmarshalException(string reason) : base(reason) + { + } + + public ProxyUnmarshalException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::ProxyUnmarshalException"; + } +} + +/// +/// This exception is raised if an out-of-bounds condition occurs during unmarshaling. +/// +public class UnmarshalOutOfBoundsException : MarshalException +{ + public UnmarshalOutOfBoundsException() + { + } + + public UnmarshalOutOfBoundsException(System.Exception ex) : base(ex) + { + } + + public UnmarshalOutOfBoundsException(string reason) : base(reason) + { + } + + public UnmarshalOutOfBoundsException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnmarshalOutOfBoundsException"; + } +} + +/// +/// This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. +/// +public class NoValueFactoryException : MarshalException +{ + public string type; + + private void _initDM() + { + this.type = ""; + } + + public NoValueFactoryException() + { + _initDM(); + } + + public NoValueFactoryException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string type) + { + this.type = type; + } + + public NoValueFactoryException(string reason, string type) : base(reason) + { + _initDM(type); + } + + public NoValueFactoryException(string reason, string type, System.Exception ex) : base(reason, ex) + { + _initDM(type); + } + + public override string ice_id() + { + return "::Ice::NoValueFactoryException"; + } +} + +/// +/// This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. +/// This +/// can happen if client and server are compiled with mismatched Slice definitions or if a class of the wrong type is +/// passed as a parameter or return value using dynamic invocation. This exception can also be raised if IceStorm is +/// used to send Slice class instances and an operation is subscribed to the wrong topic. +/// +public class UnexpectedObjectException : MarshalException +{ + public string type; + public string expectedType; + + private void _initDM() + { + this.type = ""; + this.expectedType = ""; + } + + public UnexpectedObjectException() + { + _initDM(); + } + + public UnexpectedObjectException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string type, string expectedType) + { + this.type = type; + this.expectedType = expectedType; + } + + public UnexpectedObjectException(string reason, string type, string expectedType) : base(reason) + { + _initDM(type, expectedType); + } + + public UnexpectedObjectException(string reason, string type, string expectedType, System.Exception ex) : base(reason, ex) + { + _initDM(type, expectedType); + } + + public override string ice_id() + { + return "::Ice::UnexpectedObjectException"; + } +} + +/// +/// This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the +/// Ice.MessageSizeMax property. +/// +public class MemoryLimitException : MarshalException +{ + public MemoryLimitException() + { + } + + public MemoryLimitException(System.Exception ex) : base(ex) + { + } + + public MemoryLimitException(string reason) : base(reason) + { + } + + public MemoryLimitException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::MemoryLimitException"; + } +} + +/// +/// This exception indicates a malformed data encapsulation. +/// +public class EncapsulationException : MarshalException +{ + public EncapsulationException() + { + } + + public EncapsulationException(System.Exception ex) : base(ex) + { + } + + public EncapsulationException(string reason) : base(reason) + { + } + + public EncapsulationException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::EncapsulationException"; + } +} + +/// +/// This exception is raised if an unsupported feature is used. +/// The unsupported feature string contains the name of the +/// unsupported feature. +/// +public class FeatureNotSupportedException : LocalException +{ + public string unsupportedFeature; + + private void _initDM() + { + this.unsupportedFeature = ""; + } + + public FeatureNotSupportedException() + { + _initDM(); + } + + public FeatureNotSupportedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string unsupportedFeature) + { + this.unsupportedFeature = unsupportedFeature; + } + + public FeatureNotSupportedException(string unsupportedFeature) + { + _initDM(unsupportedFeature); + } + + public FeatureNotSupportedException(string unsupportedFeature, System.Exception ex) : base(ex) + { + _initDM(unsupportedFeature); + } + + public override string ice_id() + { + return "::Ice::FeatureNotSupportedException"; + } +} + +/// +/// This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. +/// +public class SecurityException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public SecurityException() + { + _initDM(); + } + + public SecurityException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public SecurityException(string reason) + { + _initDM(reason); + } + + public SecurityException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::SecurityException"; + } +} + +/// +/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. +/// +public class FixedProxyException : LocalException +{ + public FixedProxyException() + { + } + + public FixedProxyException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::FixedProxyException"; + } +} diff --git a/csharp/src/Ice/UserException.cs b/csharp/src/Ice/UserException.cs new file mode 100644 index 00000000000..a445640ea51 --- /dev/null +++ b/csharp/src/Ice/UserException.cs @@ -0,0 +1,38 @@ +// Copyright (c) ZeroC, Inc. + +#nullable enable + +namespace Ice; + +/// +/// Base class for exceptions defined in Slice. +/// +public abstract class UserException : Exception +{ + public virtual void iceWrite(OutputStream ostr) + { + ostr.startException(); + iceWriteImpl(ostr); + ostr.endException(); + } + + public virtual void iceRead(InputStream istr) + { + istr.startException(); + iceReadImpl(istr); + istr.endException(); + } + + public virtual bool iceUsesClasses() => false; + + /// + /// Constructs an Ice user exception. + /// + protected UserException(System.Exception? innerException = null) + : base(message: null, innerException) + { + } + + protected abstract void iceWriteImpl(OutputStream ostr); + protected abstract void iceReadImpl(InputStream istr); +} diff --git a/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs b/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs index 426b351b056..adf5a3e096a 100644 --- a/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs +++ b/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs @@ -116,21 +116,15 @@ private void exception(Ice.Current current) } else if (current.operation == "unknownUserException") { - var ex = new Ice.UnknownUserException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownUserException("reason"); } else if (current.operation == "unknownLocalException") { - var ex = new Ice.UnknownLocalException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownLocalException("reason"); } else if (current.operation == "unknownException") { - var ex = new Ice.UnknownException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownException("reason"); } else if (current.operation == "userException") { diff --git a/csharp/test/Ice/servantLocator/ServantLocatorI.cs b/csharp/test/Ice/servantLocator/ServantLocatorI.cs index 971f8c5ff66..bf8ecc624ad 100644 --- a/csharp/test/Ice/servantLocator/ServantLocatorI.cs +++ b/csharp/test/Ice/servantLocator/ServantLocatorI.cs @@ -114,21 +114,15 @@ private void exception(Ice.Current current) } else if (current.operation == "unknownUserException") { - var ex = new Ice.UnknownUserException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownUserException("reason"); } else if (current.operation == "unknownLocalException") { - var ex = new Ice.UnknownLocalException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownLocalException("reason"); } else if (current.operation == "unknownException") { - var ex = new Ice.UnknownException(); - ex.unknown = "reason"; - throw ex; + throw new Ice.UnknownException("reason"); } else if (current.operation == "userException") { From aa1cba47829c7457b1a978420f077a4fb99d5099 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 16:03:02 -0400 Subject: [PATCH 02/21] Checkpoint --- CHANGELOG-3.8.md | 15 + csharp/src/Ice/DispatchExceptions.cs | 145 --- csharp/src/Ice/LocalExceptions.cs | 1751 +------------------------ csharp/src/Ice/OldLocalExceptions.cs | 1785 ++++++++++++++++++++++++++ 4 files changed, 1857 insertions(+), 1839 deletions(-) delete mode 100644 csharp/src/Ice/DispatchExceptions.cs create mode 100644 csharp/src/Ice/OldLocalExceptions.cs diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index f3e0cbf5adc..a3aa41e3efd 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -58,6 +58,21 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG (the unit is seconds). You can also override this value for a specific object adapter with the configuration property `AdapterName.Connection.CloseTimeout`. +- Consolidate and refactor the exceptions derived from LocalException. + | Local exception in Ice 3.7 | Replacement | + |----------------------------------|-----------------------| + | EndpointParseException | ParseException | + | EndpointSelectionTypeParseException | ParseException | + | IllegalIdentityException | Argument exception from standard library | + | IllegalServantException | Argument exception from standard library | + | IdentityParseException | ParseException | + | ProxyParseException | ParseException | + | VersionParseException | ParseException | + | + + New exceptions:\ + ConnectionIdleException, + ## Slice Language Changes - Removed support for the `["preserve-slice"]` metadata. Slice classes encoded in the Sliced-format are now always diff --git a/csharp/src/Ice/DispatchExceptions.cs b/csharp/src/Ice/DispatchExceptions.cs deleted file mode 100644 index 483de3896c0..00000000000 --- a/csharp/src/Ice/DispatchExceptions.cs +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright (c) ZeroC, Inc. - -#nullable enable - -namespace Ice; - -// This file contains the 6 special local exceptions that can be marshaled in an Ice reply message. - -/// -/// The base exception for the 3 NotExist exceptions. -/// -public class RequestFailedException : LocalException -{ - public Identity id; - public string facet; - public string operation; - - protected RequestFailedException( - Identity id, - string facet, - string operation, - System.Exception? innerException = null) - : base(message: null, innerException) - { - this.id = id; - this.facet = facet; - this.operation = operation; - } -} - -/// -/// The dispatch could not find a servant for the identity carried by the request. -/// -public class ObjectNotExistException : RequestFailedException -{ - public ObjectNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) - { - } - - public ObjectNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) - { - } - - public override string ice_id() - { - return "::Ice::ObjectNotExistException"; - } -} - -/// -/// The dispatch could not find a servant for the identity + facet carried by the request. -/// -public class FacetNotExistException : RequestFailedException -{ - public FacetNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) - { - } - - public FacetNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) - { - } - - public override string ice_id() - { - return "::Ice::FacetNotExistException"; - } -} - -/// -/// The dispatch could not find the operation carried by the request on the target servant. This is typically due -/// to a mismatch in the Slice definitions, such as the client using Slice definitions newer than the server's. -/// -public class OperationNotExistException : RequestFailedException -{ - public OperationNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) - { - } - - public OperationNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) - { - } - - public override string ice_id() - { - return "::Ice::OperationNotExistException"; - } -} - -/// -/// The dispatch failed with an exception that is not a or a . -/// -public class UnknownException : LocalException -{ - public string unknown => Message; - - public UnknownException(string message, System.Exception? innerException = null) - : base(message, innerException) - { - } - - public override string ice_id() - { - return "::Ice::UnknownException"; - } -} - -/// -/// The dispatch failed with a that is not one of the special marshal-able local -/// exception. -/// -public class UnknownLocalException : UnknownException -{ - public UnknownLocalException(string message, LocalException? innerException = null) - : base(message, innerException) - { - } - - public override string ice_id() - { - return "::Ice::UnknownLocalException"; - } -} - -/// -/// The dispatch returned a that was not declared in the operation's exception -/// specification. -/// -public class UnknownUserException : UnknownException -{ - public UnknownUserException(string message) - : base(message, innerException: null) - { - } - - public override string ice_id() - { - return "::Ice::UnknownUserException"; - } -} diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 9952ddb356f..93f8d1f37a8 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -1,1785 +1,148 @@ // Copyright (c) ZeroC, Inc. -namespace Ice; - -/// -/// This exception is raised when a failure occurs during initialization. -/// -public class InitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public InitializationException() - { - _initDM(); - } - - public InitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public InitializationException(string reason) - { - _initDM(reason); - } - - public InitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::InitializationException"; - } -} - -/// -/// This exception indicates that a failure occurred while initializing a plug-in. -/// -public class PluginInitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public PluginInitializationException() - { - _initDM(); - } - - public PluginInitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public PluginInitializationException(string reason) - { - _initDM(reason); - } - - public PluginInitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::PluginInitializationException"; - } -} - -/// -/// An attempt was made to register something more than once with the Ice run time. -/// This exception is raised if an -/// attempt is made to register a servant, servant locator, facet, value factory, plug-in, object adapter, object, or -/// user exception factory more than once for the same ID. -/// -public class AlreadyRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public AlreadyRegisteredException() - { - _initDM(); - } - - public AlreadyRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } - - public AlreadyRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } - - [System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")] - public AlreadyRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } - - public override string ice_id() - { - return "::Ice::AlreadyRegisteredException"; - } -} - -/// -/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. -/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, -/// object adapter, object, or user exception factory that is not currently registered. It's also raised if the Ice -/// locator can't find an object or object adapter when resolving an indirect proxy or when an object adapter is -/// activated. -/// -public class NotRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public NotRegisteredException() - { - _initDM(); - } - - public NotRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } +#nullable enable - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } +namespace Ice; - public NotRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } +// This file contains all the exception classes derived from LocalException. - public NotRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } - public override string ice_id() - { - return "::Ice::NotRegisteredException"; - } -} +// The 3 NotExist exceptions and the 3 Unknown exceptions are special local exceptions that can be marshaled in an Ice +// reply message. Other local exceptions can't be marshaled. /// -/// The operation can only be invoked with a twoway request. -/// This exception is raised if an attempt is made to invoke -/// an operation with ice_oneway, ice_batchOneway, ice_datagram, or -/// ice_batchDatagram and the operation has a return value, out-parameters, or an exception specification. +/// The base exception for the 3 NotExist exceptions. /// -public class TwowayOnlyException : LocalException +public class RequestFailedException : LocalException { + public Identity id; + public string facet; public string operation; - private void _initDM() - { - this.operation = ""; - } - - public TwowayOnlyException() - { - _initDM(); - } - - public TwowayOnlyException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string operation) + protected RequestFailedException( + Identity id, + string facet, + string operation, + System.Exception? innerException = null) + : base(message: null, innerException) { + this.id = id; + this.facet = facet; this.operation = operation; } - - public TwowayOnlyException(string operation) - { - _initDM(operation); - } - - public TwowayOnlyException(string operation, System.Exception ex) : base(ex) - { - _initDM(operation); - } - - public override string ice_id() - { - return "::Ice::TwowayOnlyException"; - } -} - -/// -/// This exception is raised if the Communicator has been destroyed. -/// -public class CommunicatorDestroyedException : LocalException -{ - public CommunicatorDestroyedException() - { - } - - public CommunicatorDestroyedException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CommunicatorDestroyedException"; - } -} - -/// -/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. -/// -public class ObjectAdapterDeactivatedException : LocalException -{ - public string name; - - private void _initDM() - { - this.name = ""; - } - - public ObjectAdapterDeactivatedException() - { - _initDM(); - } - - public ObjectAdapterDeactivatedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string name) - { - this.name = name; - } - - public ObjectAdapterDeactivatedException(string name) - { - _initDM(name); - } - - public ObjectAdapterDeactivatedException(string name, System.Exception ex) : base(ex) - { - _initDM(name); - } - - public override string ice_id() - { - return "::Ice::ObjectAdapterDeactivatedException"; - } } /// -/// This exception is raised if an ObjectAdapter cannot be activated. -/// This happens if the Locator -/// detects another active ObjectAdapter with the same adapter id. +/// The dispatch could not find a servant for the identity carried by the request. /// -public class ObjectAdapterIdInUseException : LocalException +public class ObjectNotExistException : RequestFailedException { - public string id; - - private void _initDM() - { - this.id = ""; - } - - public ObjectAdapterIdInUseException() - { - _initDM(); - } - - public ObjectAdapterIdInUseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string id) - { - this.id = id; - } - - public ObjectAdapterIdInUseException(string id) + public ObjectNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) { - _initDM(id); } - public ObjectAdapterIdInUseException(string id, System.Exception ex) : base(ex) + public ObjectNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) { - _initDM(id); } public override string ice_id() { - return "::Ice::ObjectAdapterIdInUseException"; + return "::Ice::ObjectNotExistException"; } } /// -/// This exception is raised if no suitable endpoint is available. +/// The dispatch could not find a servant for the identity + facet carried by the request. /// -public class NoEndpointException : LocalException +public class FacetNotExistException : RequestFailedException { - public string proxy; - - private void _initDM() - { - this.proxy = ""; - } - - public NoEndpointException() - { - _initDM(); - } - - public NoEndpointException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string proxy) - { - this.proxy = proxy; - } - - public NoEndpointException(string proxy) + public FacetNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) { - _initDM(proxy); } - public NoEndpointException(string proxy, System.Exception ex) : base(ex) + public FacetNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) { - _initDM(proxy); } public override string ice_id() { - return "::Ice::NoEndpointException"; + return "::Ice::FacetNotExistException"; } } /// -/// This exception is raised if there was an error while parsing an endpoint. +/// The dispatch could not find the operation carried by the request on the target servant. This is typically due +/// to a mismatch in the Slice definitions, such as the client using Slice definitions newer than the server's. /// -public class EndpointParseException : LocalException +public class OperationNotExistException : RequestFailedException { - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointParseException() - { - _initDM(); - } - - public EndpointParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointParseException(string str) + public OperationNotExistException(System.Exception? innerException = null) + : base(new Identity(), "", "", innerException) { - _initDM(str); } - public EndpointParseException(string str, System.Exception ex) : base(ex) + public OperationNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) + : base(id, facet, operation, innerException) { - _initDM(str); } public override string ice_id() { - return "::Ice::EndpointParseException"; + return "::Ice::OperationNotExistException"; } } /// -/// This exception is raised if there was an error while parsing an endpoint selection type. +/// The dispatch failed with an exception that is not a or a . /// -public class EndpointSelectionTypeParseException : LocalException +public class UnknownException : LocalException { - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointSelectionTypeParseException() - { - _initDM(); - } - - public EndpointSelectionTypeParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointSelectionTypeParseException(string str) - { - _initDM(str); - } + public string unknown => Message; - public EndpointSelectionTypeParseException(string str, System.Exception ex) : base(ex) + public UnknownException(string message, System.Exception? innerException = null) + : base(message, innerException) { - _initDM(str); } public override string ice_id() { - return "::Ice::EndpointSelectionTypeParseException"; + return "::Ice::UnknownException"; } } /// -/// This exception is raised if there was an error while parsing a version. +/// The dispatch failed with a that is not one of the special marshal-able local +/// exception. /// -public class VersionParseException : LocalException +public class UnknownLocalException : UnknownException { - public string str; - - private void _initDM() - { - this.str = ""; - } - - public VersionParseException() - { - _initDM(); - } - - public VersionParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public VersionParseException(string str) - { - _initDM(str); - } - - public VersionParseException(string str, System.Exception ex) : base(ex) + public UnknownLocalException(string message, LocalException? innerException = null) + : base(message, innerException) { - _initDM(str); } public override string ice_id() { - return "::Ice::VersionParseException"; + return "::Ice::UnknownLocalException"; } } /// -/// This exception is raised if there was an error while parsing a stringified identity. +/// The dispatch returned a that was not declared in the operation's exception +/// specification. /// -public class IdentityParseException : LocalException +public class UnknownUserException : UnknownException { - public string str; - - private void _initDM() - { - this.str = ""; - } - - public IdentityParseException() - { - _initDM(); - } - - public IdentityParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public IdentityParseException(string str) - { - _initDM(str); - } - - public IdentityParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::IdentityParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a stringified proxy. -/// -public class ProxyParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public ProxyParseException() - { - _initDM(); - } - - public ProxyParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public ProxyParseException(string str) - { - _initDM(str); - } - - public ProxyParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::ProxyParseException"; - } -} - -/// -/// This exception is raised if an illegal identity is encountered. -/// -public class IllegalIdentityException : LocalException -{ - public Identity id; - - private void _initDM() - { - this.id = new Identity(); - } - - public IllegalIdentityException() - { - _initDM(); - } - - public IllegalIdentityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(Identity id) - { - this.id = id; - } - - public IllegalIdentityException(Identity id) - { - _initDM(id); - } - - public IllegalIdentityException(Identity id, System.Exception ex) : base(ex) - { - _initDM(id); - } - - public override string ice_id() - { - return "::Ice::IllegalIdentityException"; - } -} - -/// -/// This exception is raised to reject an illegal servant (typically a null servant). -/// -public class IllegalServantException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public IllegalServantException() - { - _initDM(); - } - - public IllegalServantException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public IllegalServantException(string reason) - { - _initDM(reason); - } - - public IllegalServantException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::IllegalServantException"; - } -} - -/// -/// This exception is raised if a system error occurred in the server or client process. -/// There are many possible causes -/// for such a system exception. For details on the cause, SyscallException.error should be inspected. -/// -public class SyscallException : LocalException -{ - public int error; - - private void _initDM() - { - this.error = 0; - } - - public SyscallException() - { - _initDM(); - } - - public SyscallException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error) - { - this.error = error; - } - - public SyscallException(int error) - { - _initDM(error); - } - - public SyscallException(int error, System.Exception ex) : base(ex) - { - _initDM(error); - } - - public override string ice_id() - { - return "::Ice::SyscallException"; - } -} - -/// -/// This exception indicates socket errors. -/// -public class SocketException : SyscallException -{ - public SocketException() - { - } - - public SocketException(System.Exception ex) : base(ex) - { - } - - public SocketException(int error) : base(error) - { - } - - public SocketException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::SocketException"; - } -} - -/// This exception indicates file errors. -public class FileException : SyscallException -{ - public string path; - - private void _initDM() - { - this.path = ""; - } - - public FileException() - { - _initDM(); - } - - public FileException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string path) - { - this.path = path; - } - - public FileException(int error, string path) : base(error) - { - _initDM(path); - } - - public FileException(int error, string path, System.Exception ex) : base(error, ex) - { - _initDM(path); - } - - public override string ice_id() - { - return "::Ice::FileException"; - } -} - -/// -/// This exception indicates connection failures. -/// -public class ConnectFailedException : SocketException -{ - public ConnectFailedException() - { - } - - public ConnectFailedException(System.Exception ex) : base(ex) - { - } - - public ConnectFailedException(int error) : base(error) - { - } - - public ConnectFailedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectFailedException"; - } -} - -/// -/// This exception indicates a connection failure for which the server host actively refuses a connection. -/// -public class ConnectionRefusedException : ConnectFailedException -{ - public ConnectionRefusedException() - { - } - - public ConnectionRefusedException(System.Exception ex) : base(ex) - { - } - - public ConnectionRefusedException(int error) : base(error) - { - } - - public ConnectionRefusedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionRefusedException"; - } -} - -/// -/// This exception indicates a lost connection. -/// -public class ConnectionLostException : SocketException -{ - public ConnectionLostException() - { - } - - public ConnectionLostException(System.Exception ex) : base(ex) - { - } - - public ConnectionLostException(int error) : base(error) - { - } - - public ConnectionLostException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionLostException"; - } -} - -/// -/// This exception indicates a DNS problem. -/// For details on the cause, DNSException.error should be inspected. -/// -public class DNSException : LocalException -{ - public int error; - public string host; - - private void _initDM() - { - this.error = 0; - this.host = ""; - } - - public DNSException() - { - _initDM(); - } - - public DNSException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error, string host) - { - this.error = error; - this.host = host; - } - - public DNSException(int error, string host) - { - _initDM(error, host); - } - - public DNSException(int error, string host, System.Exception ex) : base(ex) - { - _initDM(error, host); - } - - public override string ice_id() - { - return "::Ice::DNSException"; - } -} - -/// -/// This exception indicates that a connection was closed gracefully. -/// -public class ConnectionClosedException : LocalException -{ - public ConnectionClosedException() - { - } - - public override string ice_id() => "::Ice::ConnectionClosedException"; -} - -/// -/// This exception indicates that a connection was aborted by the idle check. -/// -public class ConnectionIdleException : LocalException -{ - public ConnectionIdleException() - { - } - - public override string ice_id() => "::Ice::ConnectionIdleException"; -} - -/// This exception indicates a timeout condition. -public class TimeoutException : LocalException -{ - public TimeoutException() - { - } - - public TimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::TimeoutException"; - } -} - -/// -/// This exception indicates a connection establishment timeout condition. -/// -public class ConnectTimeoutException : TimeoutException -{ - public ConnectTimeoutException() - { - } - - public ConnectTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectTimeoutException"; - } -} - -/// This exception indicates a connection closure timeout condition. -public class CloseTimeoutException : TimeoutException -{ - public CloseTimeoutException() - { - } - - public CloseTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseTimeoutException"; - } -} - -/// -/// This exception indicates that an invocation failed because it timed out. -/// -public class InvocationTimeoutException : TimeoutException -{ - public InvocationTimeoutException() - { - } - - public InvocationTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationTimeoutException"; - } -} - -/// -/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. -/// -public class InvocationCanceledException : LocalException -{ - public InvocationCanceledException() - { - } - - public InvocationCanceledException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationCanceledException"; - } -} - -/// -/// A generic exception base for all kinds of protocol error conditions. -/// -public class ProtocolException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public ProtocolException() - { - _initDM(); - } - - public ProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public ProtocolException(string reason) - { - _initDM(reason); - } - - public ProtocolException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::ProtocolException"; - } -} - -/// -/// This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). -/// -public class BadMagicException : ProtocolException -{ - public byte[] badMagic; - - public BadMagicException() - { - } - - public BadMagicException(System.Exception ex) : base(ex) - { - } - - private void _initDM(byte[] badMagic) - { - this.badMagic = badMagic; - } - - public BadMagicException(string reason, byte[] badMagic) : base(reason) - { - _initDM(badMagic); - } - - public BadMagicException(string reason, byte[] badMagic, System.Exception ex) : base(reason, ex) - { - _initDM(badMagic); - } - - public override string ice_id() - { - return "::Ice::BadMagicException"; - } -} - -/// -/// This exception indicates an unsupported protocol version. -/// -public class UnsupportedProtocolException : ProtocolException -{ - public ProtocolVersion bad; - public ProtocolVersion supported; - - private void _initDM() - { - this.bad = new ProtocolVersion(); - this.supported = new ProtocolVersion(); - } - - public UnsupportedProtocolException() - { - _initDM(); - } - - public UnsupportedProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(ProtocolVersion bad, ProtocolVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - - public override string ice_id() - { - return "::Ice::UnsupportedProtocolException"; - } -} - -/// -/// This exception indicates an unsupported data encoding version. -/// -public class UnsupportedEncodingException : ProtocolException -{ - public EncodingVersion bad; - public EncodingVersion supported; - - private void _initDM() - { - this.bad = new EncodingVersion(); - this.supported = new EncodingVersion(); - } - - public UnsupportedEncodingException() - { - _initDM(); - } - - public UnsupportedEncodingException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(EncodingVersion bad, EncodingVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - public override string ice_id() - { - return "::Ice::UnsupportedEncodingException"; - } -} - -/// -/// This exception indicates that an unknown protocol message has been received. -/// -public class UnknownMessageException : ProtocolException -{ - public UnknownMessageException() - { - } - - public UnknownMessageException(System.Exception ex) : base(ex) - { - } - - public UnknownMessageException(string reason) : base(reason) - { - } - - public UnknownMessageException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownMessageException"; - } -} - -/// -/// This exception is raised if a message is received over a connection that is not yet validated. -/// -public class ConnectionNotValidatedException : ProtocolException -{ - public ConnectionNotValidatedException() - { - } - - public ConnectionNotValidatedException(System.Exception ex) : base(ex) - { - } - - public ConnectionNotValidatedException(string reason) : base(reason) - { - } - - public ConnectionNotValidatedException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionNotValidatedException"; - } -} - -/// -/// This exception indicates that an unknown reply status has been received. -/// -public class UnknownReplyStatusException : ProtocolException -{ - public UnknownReplyStatusException() - { - } - - public UnknownReplyStatusException(System.Exception ex) : base(ex) - { - } - - public UnknownReplyStatusException(string reason) : base(reason) - { - } - - public UnknownReplyStatusException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownReplyStatusException"; - } -} - -/// -/// This exception indicates that the connection has been gracefully shut down by the server. -/// The operation call that -/// caused this exception has not been executed by the server. In most cases you will not get this exception, because -/// the client will automatically retry the operation call in case the server shut down the connection. However, if -/// upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is -/// propagated to the application code. -/// -public class CloseConnectionException : ProtocolException -{ - public CloseConnectionException() - { - } - - public CloseConnectionException(System.Exception ex) : base(ex) - { - } - - public CloseConnectionException(string reason) : base(reason) - { - } - - public CloseConnectionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseConnectionException"; - } -} - -/// -/// This exception is raised by an operation call if the application closes the connection locally using -/// Connection.close. -/// -public class ConnectionManuallyClosedException : LocalException -{ - public bool graceful; - - private void _initDM() - { - } - - public ConnectionManuallyClosedException() - { - _initDM(); - } - - public ConnectionManuallyClosedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(bool graceful) - { - this.graceful = graceful; - } - - public ConnectionManuallyClosedException(bool graceful) - { - _initDM(graceful); - } - - public ConnectionManuallyClosedException(bool graceful, System.Exception ex) : base(ex) - { - _initDM(graceful); - } - - public override string ice_id() - { - return "::Ice::ConnectionManuallyClosedException"; - } -} - -/// -/// This exception indicates that a message size is less than the minimum required size. -/// -public class IllegalMessageSizeException : ProtocolException -{ - public IllegalMessageSizeException() - { - } - - public IllegalMessageSizeException(System.Exception ex) : base(ex) - { - } - - public IllegalMessageSizeException(string reason) : base(reason) - { - } - - public IllegalMessageSizeException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::IllegalMessageSizeException"; - } -} - -/// -/// This exception indicates a problem with compressing or uncompressing data. -/// -public class CompressionException : ProtocolException -{ - public CompressionException() - { - } - - public CompressionException(System.Exception ex) : base(ex) - { - } - - public CompressionException(string reason) : base(reason) - { - } - - public CompressionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CompressionException"; - } -} - -/// -/// A datagram exceeds the configured size. -/// This exception is raised if a datagram exceeds the configured send or -/// receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). -/// -public class DatagramLimitException : ProtocolException -{ - public DatagramLimitException() - { - } - - public DatagramLimitException(System.Exception ex) : base(ex) - { - } - - public DatagramLimitException(string reason) : base(reason) - { - } - - public DatagramLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - public override string ice_id() - { - return "::Ice::DatagramLimitException"; - } -} - -/// -/// This exception is raised for errors during marshaling or unmarshaling data. -/// -public class MarshalException : ProtocolException -{ - public MarshalException() - { - } - - public MarshalException(System.Exception ex) : base(ex) - { - } - - public MarshalException(string reason) : base(reason) - { - } - - public MarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MarshalException"; - } -} - -/// -/// This exception is raised if inconsistent data is received while unmarshaling a proxy. -/// -public class ProxyUnmarshalException : MarshalException -{ - public ProxyUnmarshalException() - { - } - - public ProxyUnmarshalException(System.Exception ex) : base(ex) - { - } - - public ProxyUnmarshalException(string reason) : base(reason) - { - } - - public ProxyUnmarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ProxyUnmarshalException"; - } -} - -/// -/// This exception is raised if an out-of-bounds condition occurs during unmarshaling. -/// -public class UnmarshalOutOfBoundsException : MarshalException -{ - public UnmarshalOutOfBoundsException() - { - } - - public UnmarshalOutOfBoundsException(System.Exception ex) : base(ex) - { - } - - public UnmarshalOutOfBoundsException(string reason) : base(reason) - { - } - - public UnmarshalOutOfBoundsException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnmarshalOutOfBoundsException"; - } -} - -/// -/// This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. -/// -public class NoValueFactoryException : MarshalException -{ - public string type; - - private void _initDM() - { - this.type = ""; - } - - public NoValueFactoryException() - { - _initDM(); - } - - public NoValueFactoryException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type) - { - this.type = type; - } - - public NoValueFactoryException(string reason, string type) : base(reason) - { - _initDM(type); - } - - public NoValueFactoryException(string reason, string type, System.Exception ex) : base(reason, ex) - { - _initDM(type); - } - - public override string ice_id() - { - return "::Ice::NoValueFactoryException"; - } -} - -/// -/// This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. -/// This -/// can happen if client and server are compiled with mismatched Slice definitions or if a class of the wrong type is -/// passed as a parameter or return value using dynamic invocation. This exception can also be raised if IceStorm is -/// used to send Slice class instances and an operation is subscribed to the wrong topic. -/// -public class UnexpectedObjectException : MarshalException -{ - public string type; - public string expectedType; - - private void _initDM() - { - this.type = ""; - this.expectedType = ""; - } - - public UnexpectedObjectException() - { - _initDM(); - } - - public UnexpectedObjectException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type, string expectedType) - { - this.type = type; - this.expectedType = expectedType; - } - - public UnexpectedObjectException(string reason, string type, string expectedType) : base(reason) - { - _initDM(type, expectedType); - } - - public UnexpectedObjectException(string reason, string type, string expectedType, System.Exception ex) : base(reason, ex) - { - _initDM(type, expectedType); - } - - public override string ice_id() - { - return "::Ice::UnexpectedObjectException"; - } -} - -/// -/// This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the -/// Ice.MessageSizeMax property. -/// -public class MemoryLimitException : MarshalException -{ - public MemoryLimitException() - { - } - - public MemoryLimitException(System.Exception ex) : base(ex) - { - } - - public MemoryLimitException(string reason) : base(reason) - { - } - - public MemoryLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MemoryLimitException"; - } -} - -/// -/// This exception indicates a malformed data encapsulation. -/// -public class EncapsulationException : MarshalException -{ - public EncapsulationException() - { - } - - public EncapsulationException(System.Exception ex) : base(ex) - { - } - - public EncapsulationException(string reason) : base(reason) - { - } - - public EncapsulationException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::EncapsulationException"; - } -} - -/// -/// This exception is raised if an unsupported feature is used. -/// The unsupported feature string contains the name of the -/// unsupported feature. -/// -public class FeatureNotSupportedException : LocalException -{ - public string unsupportedFeature; - - private void _initDM() - { - this.unsupportedFeature = ""; - } - - public FeatureNotSupportedException() - { - _initDM(); - } - - public FeatureNotSupportedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string unsupportedFeature) - { - this.unsupportedFeature = unsupportedFeature; - } - - public FeatureNotSupportedException(string unsupportedFeature) - { - _initDM(unsupportedFeature); - } - - public FeatureNotSupportedException(string unsupportedFeature, System.Exception ex) : base(ex) - { - _initDM(unsupportedFeature); - } - - public override string ice_id() - { - return "::Ice::FeatureNotSupportedException"; - } -} - -/// -/// This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. -/// -public class SecurityException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public SecurityException() - { - _initDM(); - } - - public SecurityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public SecurityException(string reason) - { - _initDM(reason); - } - - public SecurityException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::SecurityException"; - } -} - -/// -/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. -/// -public class FixedProxyException : LocalException -{ - public FixedProxyException() - { - } - - public FixedProxyException(System.Exception ex) : base(ex) + public UnknownUserException(string message) + : base(message, innerException: null) { } public override string ice_id() { - return "::Ice::FixedProxyException"; + return "::Ice::UnknownUserException"; } } diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs new file mode 100644 index 00000000000..9952ddb356f --- /dev/null +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -0,0 +1,1785 @@ +// Copyright (c) ZeroC, Inc. + +namespace Ice; + +/// +/// This exception is raised when a failure occurs during initialization. +/// +public class InitializationException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public InitializationException() + { + _initDM(); + } + + public InitializationException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public InitializationException(string reason) + { + _initDM(reason); + } + + public InitializationException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::InitializationException"; + } +} + +/// +/// This exception indicates that a failure occurred while initializing a plug-in. +/// +public class PluginInitializationException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public PluginInitializationException() + { + _initDM(); + } + + public PluginInitializationException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public PluginInitializationException(string reason) + { + _initDM(reason); + } + + public PluginInitializationException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::PluginInitializationException"; + } +} + +/// +/// An attempt was made to register something more than once with the Ice run time. +/// This exception is raised if an +/// attempt is made to register a servant, servant locator, facet, value factory, plug-in, object adapter, object, or +/// user exception factory more than once for the same ID. +/// +public class AlreadyRegisteredException : LocalException +{ + public string kindOfObject; + public string id; + + private void _initDM() + { + this.kindOfObject = ""; + this.id = ""; + } + + public AlreadyRegisteredException() + { + _initDM(); + } + + public AlreadyRegisteredException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string kindOfObject, string id) + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public AlreadyRegisteredException(string kindOfObject, string id) + { + _initDM(kindOfObject, id); + } + + [System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")] + public AlreadyRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) + { + _initDM(kindOfObject, id); + } + + public override string ice_id() + { + return "::Ice::AlreadyRegisteredException"; + } +} + +/// +/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. +/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, +/// object adapter, object, or user exception factory that is not currently registered. It's also raised if the Ice +/// locator can't find an object or object adapter when resolving an indirect proxy or when an object adapter is +/// activated. +/// +public class NotRegisteredException : LocalException +{ + public string kindOfObject; + public string id; + + private void _initDM() + { + this.kindOfObject = ""; + this.id = ""; + } + + public NotRegisteredException() + { + _initDM(); + } + + public NotRegisteredException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string kindOfObject, string id) + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public NotRegisteredException(string kindOfObject, string id) + { + _initDM(kindOfObject, id); + } + + public NotRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) + { + _initDM(kindOfObject, id); + } + public override string ice_id() + { + return "::Ice::NotRegisteredException"; + } +} + +/// +/// The operation can only be invoked with a twoway request. +/// This exception is raised if an attempt is made to invoke +/// an operation with ice_oneway, ice_batchOneway, ice_datagram, or +/// ice_batchDatagram and the operation has a return value, out-parameters, or an exception specification. +/// +public class TwowayOnlyException : LocalException +{ + public string operation; + + private void _initDM() + { + this.operation = ""; + } + + public TwowayOnlyException() + { + _initDM(); + } + + public TwowayOnlyException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string operation) + { + this.operation = operation; + } + + public TwowayOnlyException(string operation) + { + _initDM(operation); + } + + public TwowayOnlyException(string operation, System.Exception ex) : base(ex) + { + _initDM(operation); + } + + public override string ice_id() + { + return "::Ice::TwowayOnlyException"; + } +} + +/// +/// This exception is raised if the Communicator has been destroyed. +/// +public class CommunicatorDestroyedException : LocalException +{ + public CommunicatorDestroyedException() + { + } + + public CommunicatorDestroyedException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::CommunicatorDestroyedException"; + } +} + +/// +/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. +/// +public class ObjectAdapterDeactivatedException : LocalException +{ + public string name; + + private void _initDM() + { + this.name = ""; + } + + public ObjectAdapterDeactivatedException() + { + _initDM(); + } + + public ObjectAdapterDeactivatedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string name) + { + this.name = name; + } + + public ObjectAdapterDeactivatedException(string name) + { + _initDM(name); + } + + public ObjectAdapterDeactivatedException(string name, System.Exception ex) : base(ex) + { + _initDM(name); + } + + public override string ice_id() + { + return "::Ice::ObjectAdapterDeactivatedException"; + } +} + +/// +/// This exception is raised if an ObjectAdapter cannot be activated. +/// This happens if the Locator +/// detects another active ObjectAdapter with the same adapter id. +/// +public class ObjectAdapterIdInUseException : LocalException +{ + public string id; + + private void _initDM() + { + this.id = ""; + } + + public ObjectAdapterIdInUseException() + { + _initDM(); + } + + public ObjectAdapterIdInUseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string id) + { + this.id = id; + } + + public ObjectAdapterIdInUseException(string id) + { + _initDM(id); + } + + public ObjectAdapterIdInUseException(string id, System.Exception ex) : base(ex) + { + _initDM(id); + } + + public override string ice_id() + { + return "::Ice::ObjectAdapterIdInUseException"; + } +} + +/// +/// This exception is raised if no suitable endpoint is available. +/// +public class NoEndpointException : LocalException +{ + public string proxy; + + private void _initDM() + { + this.proxy = ""; + } + + public NoEndpointException() + { + _initDM(); + } + + public NoEndpointException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string proxy) + { + this.proxy = proxy; + } + + public NoEndpointException(string proxy) + { + _initDM(proxy); + } + + public NoEndpointException(string proxy, System.Exception ex) : base(ex) + { + _initDM(proxy); + } + + public override string ice_id() + { + return "::Ice::NoEndpointException"; + } +} + +/// +/// This exception is raised if there was an error while parsing an endpoint. +/// +public class EndpointParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public EndpointParseException() + { + _initDM(); + } + + public EndpointParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public EndpointParseException(string str) + { + _initDM(str); + } + + public EndpointParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::EndpointParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing an endpoint selection type. +/// +public class EndpointSelectionTypeParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public EndpointSelectionTypeParseException() + { + _initDM(); + } + + public EndpointSelectionTypeParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public EndpointSelectionTypeParseException(string str) + { + _initDM(str); + } + + public EndpointSelectionTypeParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::EndpointSelectionTypeParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a version. +/// +public class VersionParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public VersionParseException() + { + _initDM(); + } + + public VersionParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public VersionParseException(string str) + { + _initDM(str); + } + + public VersionParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::VersionParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a stringified identity. +/// +public class IdentityParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public IdentityParseException() + { + _initDM(); + } + + public IdentityParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public IdentityParseException(string str) + { + _initDM(str); + } + + public IdentityParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::IdentityParseException"; + } +} + +/// +/// This exception is raised if there was an error while parsing a stringified proxy. +/// +public class ProxyParseException : LocalException +{ + public string str; + + private void _initDM() + { + this.str = ""; + } + + public ProxyParseException() + { + _initDM(); + } + + public ProxyParseException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string str) + { + this.str = str; + } + + public ProxyParseException(string str) + { + _initDM(str); + } + + public ProxyParseException(string str, System.Exception ex) : base(ex) + { + _initDM(str); + } + + public override string ice_id() + { + return "::Ice::ProxyParseException"; + } +} + +/// +/// This exception is raised if an illegal identity is encountered. +/// +public class IllegalIdentityException : LocalException +{ + public Identity id; + + private void _initDM() + { + this.id = new Identity(); + } + + public IllegalIdentityException() + { + _initDM(); + } + + public IllegalIdentityException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(Identity id) + { + this.id = id; + } + + public IllegalIdentityException(Identity id) + { + _initDM(id); + } + + public IllegalIdentityException(Identity id, System.Exception ex) : base(ex) + { + _initDM(id); + } + + public override string ice_id() + { + return "::Ice::IllegalIdentityException"; + } +} + +/// +/// This exception is raised to reject an illegal servant (typically a null servant). +/// +public class IllegalServantException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public IllegalServantException() + { + _initDM(); + } + + public IllegalServantException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public IllegalServantException(string reason) + { + _initDM(reason); + } + + public IllegalServantException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::IllegalServantException"; + } +} + +/// +/// This exception is raised if a system error occurred in the server or client process. +/// There are many possible causes +/// for such a system exception. For details on the cause, SyscallException.error should be inspected. +/// +public class SyscallException : LocalException +{ + public int error; + + private void _initDM() + { + this.error = 0; + } + + public SyscallException() + { + _initDM(); + } + + public SyscallException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(int error) + { + this.error = error; + } + + public SyscallException(int error) + { + _initDM(error); + } + + public SyscallException(int error, System.Exception ex) : base(ex) + { + _initDM(error); + } + + public override string ice_id() + { + return "::Ice::SyscallException"; + } +} + +/// +/// This exception indicates socket errors. +/// +public class SocketException : SyscallException +{ + public SocketException() + { + } + + public SocketException(System.Exception ex) : base(ex) + { + } + + public SocketException(int error) : base(error) + { + } + + public SocketException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::SocketException"; + } +} + +/// This exception indicates file errors. +public class FileException : SyscallException +{ + public string path; + + private void _initDM() + { + this.path = ""; + } + + public FileException() + { + _initDM(); + } + + public FileException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string path) + { + this.path = path; + } + + public FileException(int error, string path) : base(error) + { + _initDM(path); + } + + public FileException(int error, string path, System.Exception ex) : base(error, ex) + { + _initDM(path); + } + + public override string ice_id() + { + return "::Ice::FileException"; + } +} + +/// +/// This exception indicates connection failures. +/// +public class ConnectFailedException : SocketException +{ + public ConnectFailedException() + { + } + + public ConnectFailedException(System.Exception ex) : base(ex) + { + } + + public ConnectFailedException(int error) : base(error) + { + } + + public ConnectFailedException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectFailedException"; + } +} + +/// +/// This exception indicates a connection failure for which the server host actively refuses a connection. +/// +public class ConnectionRefusedException : ConnectFailedException +{ + public ConnectionRefusedException() + { + } + + public ConnectionRefusedException(System.Exception ex) : base(ex) + { + } + + public ConnectionRefusedException(int error) : base(error) + { + } + + public ConnectionRefusedException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionRefusedException"; + } +} + +/// +/// This exception indicates a lost connection. +/// +public class ConnectionLostException : SocketException +{ + public ConnectionLostException() + { + } + + public ConnectionLostException(System.Exception ex) : base(ex) + { + } + + public ConnectionLostException(int error) : base(error) + { + } + + public ConnectionLostException(int error, System.Exception ex) : base(error, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionLostException"; + } +} + +/// +/// This exception indicates a DNS problem. +/// For details on the cause, DNSException.error should be inspected. +/// +public class DNSException : LocalException +{ + public int error; + public string host; + + private void _initDM() + { + this.error = 0; + this.host = ""; + } + + public DNSException() + { + _initDM(); + } + + public DNSException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(int error, string host) + { + this.error = error; + this.host = host; + } + + public DNSException(int error, string host) + { + _initDM(error, host); + } + + public DNSException(int error, string host, System.Exception ex) : base(ex) + { + _initDM(error, host); + } + + public override string ice_id() + { + return "::Ice::DNSException"; + } +} + +/// +/// This exception indicates that a connection was closed gracefully. +/// +public class ConnectionClosedException : LocalException +{ + public ConnectionClosedException() + { + } + + public override string ice_id() => "::Ice::ConnectionClosedException"; +} + +/// +/// This exception indicates that a connection was aborted by the idle check. +/// +public class ConnectionIdleException : LocalException +{ + public ConnectionIdleException() + { + } + + public override string ice_id() => "::Ice::ConnectionIdleException"; +} + +/// This exception indicates a timeout condition. +public class TimeoutException : LocalException +{ + public TimeoutException() + { + } + + public TimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::TimeoutException"; + } +} + +/// +/// This exception indicates a connection establishment timeout condition. +/// +public class ConnectTimeoutException : TimeoutException +{ + public ConnectTimeoutException() + { + } + + public ConnectTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectTimeoutException"; + } +} + +/// This exception indicates a connection closure timeout condition. +public class CloseTimeoutException : TimeoutException +{ + public CloseTimeoutException() + { + } + + public CloseTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::CloseTimeoutException"; + } +} + +/// +/// This exception indicates that an invocation failed because it timed out. +/// +public class InvocationTimeoutException : TimeoutException +{ + public InvocationTimeoutException() + { + } + + public InvocationTimeoutException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::InvocationTimeoutException"; + } +} + +/// +/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. +/// +public class InvocationCanceledException : LocalException +{ + public InvocationCanceledException() + { + } + + public InvocationCanceledException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::InvocationCanceledException"; + } +} + +/// +/// A generic exception base for all kinds of protocol error conditions. +/// +public class ProtocolException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public ProtocolException() + { + _initDM(); + } + + public ProtocolException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public ProtocolException(string reason) + { + _initDM(reason); + } + + public ProtocolException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::ProtocolException"; + } +} + +/// +/// This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). +/// +public class BadMagicException : ProtocolException +{ + public byte[] badMagic; + + public BadMagicException() + { + } + + public BadMagicException(System.Exception ex) : base(ex) + { + } + + private void _initDM(byte[] badMagic) + { + this.badMagic = badMagic; + } + + public BadMagicException(string reason, byte[] badMagic) : base(reason) + { + _initDM(badMagic); + } + + public BadMagicException(string reason, byte[] badMagic, System.Exception ex) : base(reason, ex) + { + _initDM(badMagic); + } + + public override string ice_id() + { + return "::Ice::BadMagicException"; + } +} + +/// +/// This exception indicates an unsupported protocol version. +/// +public class UnsupportedProtocolException : ProtocolException +{ + public ProtocolVersion bad; + public ProtocolVersion supported; + + private void _initDM() + { + this.bad = new ProtocolVersion(); + this.supported = new ProtocolVersion(); + } + + public UnsupportedProtocolException() + { + _initDM(); + } + + public UnsupportedProtocolException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(ProtocolVersion bad, ProtocolVersion supported) + { + this.bad = bad; + this.supported = supported; + } + + public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported) : base(reason) + { + _initDM(bad, supported); + } + + public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported, System.Exception ex) : base(reason, ex) + { + _initDM(bad, supported); + } + + public override string ice_id() + { + return "::Ice::UnsupportedProtocolException"; + } +} + +/// +/// This exception indicates an unsupported data encoding version. +/// +public class UnsupportedEncodingException : ProtocolException +{ + public EncodingVersion bad; + public EncodingVersion supported; + + private void _initDM() + { + this.bad = new EncodingVersion(); + this.supported = new EncodingVersion(); + } + + public UnsupportedEncodingException() + { + _initDM(); + } + + public UnsupportedEncodingException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(EncodingVersion bad, EncodingVersion supported) + { + this.bad = bad; + this.supported = supported; + } + + public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported) : base(reason) + { + _initDM(bad, supported); + } + + public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported, System.Exception ex) : base(reason, ex) + { + _initDM(bad, supported); + } + public override string ice_id() + { + return "::Ice::UnsupportedEncodingException"; + } +} + +/// +/// This exception indicates that an unknown protocol message has been received. +/// +public class UnknownMessageException : ProtocolException +{ + public UnknownMessageException() + { + } + + public UnknownMessageException(System.Exception ex) : base(ex) + { + } + + public UnknownMessageException(string reason) : base(reason) + { + } + + public UnknownMessageException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnknownMessageException"; + } +} + +/// +/// This exception is raised if a message is received over a connection that is not yet validated. +/// +public class ConnectionNotValidatedException : ProtocolException +{ + public ConnectionNotValidatedException() + { + } + + public ConnectionNotValidatedException(System.Exception ex) : base(ex) + { + } + + public ConnectionNotValidatedException(string reason) : base(reason) + { + } + + public ConnectionNotValidatedException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::ConnectionNotValidatedException"; + } +} + +/// +/// This exception indicates that an unknown reply status has been received. +/// +public class UnknownReplyStatusException : ProtocolException +{ + public UnknownReplyStatusException() + { + } + + public UnknownReplyStatusException(System.Exception ex) : base(ex) + { + } + + public UnknownReplyStatusException(string reason) : base(reason) + { + } + + public UnknownReplyStatusException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnknownReplyStatusException"; + } +} + +/// +/// This exception indicates that the connection has been gracefully shut down by the server. +/// The operation call that +/// caused this exception has not been executed by the server. In most cases you will not get this exception, because +/// the client will automatically retry the operation call in case the server shut down the connection. However, if +/// upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is +/// propagated to the application code. +/// +public class CloseConnectionException : ProtocolException +{ + public CloseConnectionException() + { + } + + public CloseConnectionException(System.Exception ex) : base(ex) + { + } + + public CloseConnectionException(string reason) : base(reason) + { + } + + public CloseConnectionException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::CloseConnectionException"; + } +} + +/// +/// This exception is raised by an operation call if the application closes the connection locally using +/// Connection.close. +/// +public class ConnectionManuallyClosedException : LocalException +{ + public bool graceful; + + private void _initDM() + { + } + + public ConnectionManuallyClosedException() + { + _initDM(); + } + + public ConnectionManuallyClosedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(bool graceful) + { + this.graceful = graceful; + } + + public ConnectionManuallyClosedException(bool graceful) + { + _initDM(graceful); + } + + public ConnectionManuallyClosedException(bool graceful, System.Exception ex) : base(ex) + { + _initDM(graceful); + } + + public override string ice_id() + { + return "::Ice::ConnectionManuallyClosedException"; + } +} + +/// +/// This exception indicates that a message size is less than the minimum required size. +/// +public class IllegalMessageSizeException : ProtocolException +{ + public IllegalMessageSizeException() + { + } + + public IllegalMessageSizeException(System.Exception ex) : base(ex) + { + } + + public IllegalMessageSizeException(string reason) : base(reason) + { + } + + public IllegalMessageSizeException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::IllegalMessageSizeException"; + } +} + +/// +/// This exception indicates a problem with compressing or uncompressing data. +/// +public class CompressionException : ProtocolException +{ + public CompressionException() + { + } + + public CompressionException(System.Exception ex) : base(ex) + { + } + + public CompressionException(string reason) : base(reason) + { + } + + public CompressionException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::CompressionException"; + } +} + +/// +/// A datagram exceeds the configured size. +/// This exception is raised if a datagram exceeds the configured send or +/// receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). +/// +public class DatagramLimitException : ProtocolException +{ + public DatagramLimitException() + { + } + + public DatagramLimitException(System.Exception ex) : base(ex) + { + } + + public DatagramLimitException(string reason) : base(reason) + { + } + + public DatagramLimitException(string reason, System.Exception ex) : base(reason, ex) + { + } + public override string ice_id() + { + return "::Ice::DatagramLimitException"; + } +} + +/// +/// This exception is raised for errors during marshaling or unmarshaling data. +/// +public class MarshalException : ProtocolException +{ + public MarshalException() + { + } + + public MarshalException(System.Exception ex) : base(ex) + { + } + + public MarshalException(string reason) : base(reason) + { + } + + public MarshalException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::MarshalException"; + } +} + +/// +/// This exception is raised if inconsistent data is received while unmarshaling a proxy. +/// +public class ProxyUnmarshalException : MarshalException +{ + public ProxyUnmarshalException() + { + } + + public ProxyUnmarshalException(System.Exception ex) : base(ex) + { + } + + public ProxyUnmarshalException(string reason) : base(reason) + { + } + + public ProxyUnmarshalException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::ProxyUnmarshalException"; + } +} + +/// +/// This exception is raised if an out-of-bounds condition occurs during unmarshaling. +/// +public class UnmarshalOutOfBoundsException : MarshalException +{ + public UnmarshalOutOfBoundsException() + { + } + + public UnmarshalOutOfBoundsException(System.Exception ex) : base(ex) + { + } + + public UnmarshalOutOfBoundsException(string reason) : base(reason) + { + } + + public UnmarshalOutOfBoundsException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::UnmarshalOutOfBoundsException"; + } +} + +/// +/// This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. +/// +public class NoValueFactoryException : MarshalException +{ + public string type; + + private void _initDM() + { + this.type = ""; + } + + public NoValueFactoryException() + { + _initDM(); + } + + public NoValueFactoryException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string type) + { + this.type = type; + } + + public NoValueFactoryException(string reason, string type) : base(reason) + { + _initDM(type); + } + + public NoValueFactoryException(string reason, string type, System.Exception ex) : base(reason, ex) + { + _initDM(type); + } + + public override string ice_id() + { + return "::Ice::NoValueFactoryException"; + } +} + +/// +/// This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. +/// This +/// can happen if client and server are compiled with mismatched Slice definitions or if a class of the wrong type is +/// passed as a parameter or return value using dynamic invocation. This exception can also be raised if IceStorm is +/// used to send Slice class instances and an operation is subscribed to the wrong topic. +/// +public class UnexpectedObjectException : MarshalException +{ + public string type; + public string expectedType; + + private void _initDM() + { + this.type = ""; + this.expectedType = ""; + } + + public UnexpectedObjectException() + { + _initDM(); + } + + public UnexpectedObjectException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string type, string expectedType) + { + this.type = type; + this.expectedType = expectedType; + } + + public UnexpectedObjectException(string reason, string type, string expectedType) : base(reason) + { + _initDM(type, expectedType); + } + + public UnexpectedObjectException(string reason, string type, string expectedType, System.Exception ex) : base(reason, ex) + { + _initDM(type, expectedType); + } + + public override string ice_id() + { + return "::Ice::UnexpectedObjectException"; + } +} + +/// +/// This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the +/// Ice.MessageSizeMax property. +/// +public class MemoryLimitException : MarshalException +{ + public MemoryLimitException() + { + } + + public MemoryLimitException(System.Exception ex) : base(ex) + { + } + + public MemoryLimitException(string reason) : base(reason) + { + } + + public MemoryLimitException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::MemoryLimitException"; + } +} + +/// +/// This exception indicates a malformed data encapsulation. +/// +public class EncapsulationException : MarshalException +{ + public EncapsulationException() + { + } + + public EncapsulationException(System.Exception ex) : base(ex) + { + } + + public EncapsulationException(string reason) : base(reason) + { + } + + public EncapsulationException(string reason, System.Exception ex) : base(reason, ex) + { + } + + public override string ice_id() + { + return "::Ice::EncapsulationException"; + } +} + +/// +/// This exception is raised if an unsupported feature is used. +/// The unsupported feature string contains the name of the +/// unsupported feature. +/// +public class FeatureNotSupportedException : LocalException +{ + public string unsupportedFeature; + + private void _initDM() + { + this.unsupportedFeature = ""; + } + + public FeatureNotSupportedException() + { + _initDM(); + } + + public FeatureNotSupportedException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string unsupportedFeature) + { + this.unsupportedFeature = unsupportedFeature; + } + + public FeatureNotSupportedException(string unsupportedFeature) + { + _initDM(unsupportedFeature); + } + + public FeatureNotSupportedException(string unsupportedFeature, System.Exception ex) : base(ex) + { + _initDM(unsupportedFeature); + } + + public override string ice_id() + { + return "::Ice::FeatureNotSupportedException"; + } +} + +/// +/// This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. +/// +public class SecurityException : LocalException +{ + public string reason; + + private void _initDM() + { + this.reason = ""; + } + + public SecurityException() + { + _initDM(); + } + + public SecurityException(System.Exception ex) : base(ex) + { + _initDM(); + } + + private void _initDM(string reason) + { + this.reason = reason; + } + + public SecurityException(string reason) + { + _initDM(reason); + } + + public SecurityException(string reason, System.Exception ex) : base(ex) + { + _initDM(reason); + } + + public override string ice_id() + { + return "::Ice::SecurityException"; + } +} + +/// +/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. +/// +public class FixedProxyException : LocalException +{ + public FixedProxyException() + { + } + + public FixedProxyException(System.Exception ex) : base(ex) + { + } + + public override string ice_id() + { + return "::Ice::FixedProxyException"; + } +} From e1df52cea7174abeaaaa840a7c7a15f9e167c442 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 16:35:51 -0400 Subject: [PATCH 03/21] Remove EndpointParseException --- csharp/src/Ice/Communicator.cs | 5 +-- .../Ice/Internal/EndpointFactoryManager.cs | 16 ++----- csharp/src/Ice/Internal/IPEndpointI.cs | 25 ++++------- csharp/src/Ice/Internal/OpaqueEndpointI.cs | 27 ++++++------ csharp/src/Ice/Internal/ReferenceFactory.cs | 4 +- csharp/src/Ice/Internal/TcpEndpointI.cs | 14 ++---- csharp/src/Ice/Internal/UdpEndpointI.cs | 35 ++++----------- csharp/src/Ice/Internal/WSEndpoint.cs | 4 +- csharp/src/Ice/LocalExceptions.cs | 25 ++++++++--- csharp/src/Ice/ObjectAdapter.cs | 6 +-- csharp/src/Ice/OldLocalExceptions.cs | 43 ------------------- csharp/test/Ice/proxy/AllTests.cs | 38 ++++++++-------- 12 files changed, 84 insertions(+), 158 deletions(-) diff --git a/csharp/src/Ice/Communicator.cs b/csharp/src/Ice/Communicator.cs index 95fd125f406..50227bba3d2 100644 --- a/csharp/src/Ice/Communicator.cs +++ b/csharp/src/Ice/Communicator.cs @@ -85,9 +85,8 @@ public bool isShutdown() /// Converts a stringified proxy into a proxy. /// For example, "MyCategory/MyObject:tcp -h some_host -p 10000" creates a proxy that refers to the Ice object /// having an identity with a name "MyObject" and a category "MyCategory", with the server running on host - /// "some_host", port 10000. If the stringified proxy does not parse correctly, this method throws one of - /// ProxyParseException, EndpointParseException, or IdentityParseException. Refer to the Ice manual for a detailed - /// description of the syntax supported by stringified proxies. + /// "some_host", port 10000. If the stringified proxy does not parse correctly, this method throws ParseException. + /// Refer to the Ice manual for a detailed description of the syntax supported by stringified proxies. /// /// The stringified proxy to convert into a proxy. /// The proxy, or null if str is an empty string. diff --git a/csharp/src/Ice/Internal/EndpointFactoryManager.cs b/csharp/src/Ice/Internal/EndpointFactoryManager.cs index dea9be2d2e5..e767c630b77 100644 --- a/csharp/src/Ice/Internal/EndpointFactoryManager.cs +++ b/csharp/src/Ice/Internal/EndpointFactoryManager.cs @@ -54,16 +54,12 @@ public EndpointI create(string str, bool oaEndpoint) string[] arr = Ice.UtilInternal.StringUtil.splitString(str, " \t\r\n"); if (arr == null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "mismatched quote"; - throw e; + throw new ParseException($"Failed to parse endpoint '{str}': mismatched quote"); } if (arr.Length == 0) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "value has no non-whitespace characters"; - throw e; + throw new ParseException($"Failed to parse endpoint '{str}': value has no non-whitespace characters"); } List v = new List(arr); @@ -94,9 +90,7 @@ public EndpointI create(string str, bool oaEndpoint) EndpointI e = factory.create(v, oaEndpoint); if (v.Count > 0) { - Ice.EndpointParseException ex = new Ice.EndpointParseException(); - ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; - throw ex; + throw new ParseException($"Failed to parse endpoint '{str}': unrecognized argument '{v[0]}'"); } return e; @@ -125,9 +119,7 @@ public EndpointI create(string str, bool oaEndpoint) EndpointI ue = new OpaqueEndpointI(v); if (v.Count > 0) { - Ice.EndpointParseException ex = new Ice.EndpointParseException(); - ex.str = "unrecognized argument `" + v[0] + "' in endpoint `" + str + "'"; - throw ex; + throw new ParseException($"Failed to parse endpoint '{str}': unrecognized argument '{v[0]}'"); } factory = get(ue.type()); if (factory != null) diff --git a/csharp/src/Ice/Internal/IPEndpointI.cs b/csharp/src/Ice/Internal/IPEndpointI.cs index 282c9d0ab51..50362876a86 100644 --- a/csharp/src/Ice/Internal/IPEndpointI.cs +++ b/csharp/src/Ice/Internal/IPEndpointI.cs @@ -314,7 +314,7 @@ public virtual void initWithOptions(List args, bool oaEndpoint) } else { - throw new Ice.EndpointParseException("`-h *' not valid for proxy endpoint `" + ToString() + "'"); + throw new ParseException($"'-h *' not valid for proxy endpoint '{ToString()}'"); } } @@ -327,8 +327,7 @@ public virtual void initWithOptions(List args, bool oaEndpoint) { if (oaEndpoint) { - throw new Ice.EndpointParseException("`--sourceAddress' not valid for object adapter endpoint `" + - ToString() + "'"); + throw new ParseException($"'--sourceAddress' not valid for object adapter endpoint '{ToString()}'"); } } else if (!oaEndpoint) @@ -343,8 +342,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -h option in endpoint " + - endpoint); + throw new ParseException($"no argument provided for -h option in endpoint '{endpoint}'"); } host_ = argument; } @@ -352,8 +350,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -p option in endpoint " + - endpoint); + throw new ParseException($"no argument provided for -p option in endpoint '{endpoint}'"); } try @@ -362,29 +359,25 @@ protected override bool checkOption(string option, string argument, string endpo } catch (FormatException ex) { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid port value `" + argument + "' in endpoint " + endpoint; - throw e; + throw new ParseException($"invalid port value '{argument}' in endpoint '{endpoint}'", ex); } if (port_ < 0 || port_ > 65535) { - throw new Ice.EndpointParseException("port value `" + argument + - "' out of range in endpoint " + endpoint); + throw new ParseException($"port value '{argument}' out of range in endpoint '{endpoint}'"); } } else if (option == "--sourceAddress") { if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for --sourceAddress option in endpoint " + - endpoint); + throw new ParseException($"no argument provided for --sourceAddress option in endpoint '{endpoint}'"); } sourceAddr_ = Network.getNumericAddress(argument); if (sourceAddr_ == null) { - throw new Ice.EndpointParseException( - "invalid IP address provided for --sourceAddress option in endpoint " + endpoint); + throw new ParseException( + $"invalid IP address provided for --sourceAddress option in endpoint '{endpoint}'"); } } else diff --git a/csharp/src/Ice/Internal/OpaqueEndpointI.cs b/csharp/src/Ice/Internal/OpaqueEndpointI.cs index 43280166711..9e0bb1135c8 100644 --- a/csharp/src/Ice/Internal/OpaqueEndpointI.cs +++ b/csharp/src/Ice/Internal/OpaqueEndpointI.cs @@ -18,11 +18,11 @@ public OpaqueEndpointI(List args) if (_type < 0) { - throw new Ice.EndpointParseException("no -t option in endpoint " + ToString()); + throw new ParseException($"no -t option in endpoint '{this}'"); } if (_rawBytes.Length == 0) { - throw new Ice.EndpointParseException("no -v option in endpoint " + ToString()); + throw new ParseException($"no -v option in endpoint '{this}'"); } } @@ -336,11 +336,11 @@ protected override bool checkOption(string option, string argument, string endpo { if (_type > -1) { - throw new Ice.EndpointParseException("multiple -t options in endpoint " + endpoint); + throw new ParseException($"multiple -t options in endpoint '{endpoint}'"); } if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + endpoint); + throw new ParseException($"no argument provided for -t option in endpoint '{endpoint}'"); } int t; @@ -348,16 +348,14 @@ protected override bool checkOption(string option, string argument, string endpo { t = System.Int32.Parse(argument, CultureInfo.InvariantCulture); } - catch (System.FormatException) + catch (FormatException ex) { - throw new Ice.EndpointParseException("invalid type value `" + argument + "' in endpoint " + - endpoint); + throw new ParseException($"invalid type value '{argument}' in endpoint '{endpoint}'", ex); } if (t < 0 || t > 65535) { - throw new Ice.EndpointParseException("type value `" + argument + "' out of range in endpoint " + - endpoint); + throw new ParseException($"type value '{argument}' out of range in endpoint '{endpoint}'"); } _type = (short)t; @@ -368,11 +366,11 @@ protected override bool checkOption(string option, string argument, string endpo { if (_rawBytes.Length > 0) { - throw new Ice.EndpointParseException("multiple -v options in endpoint " + endpoint); + throw new ParseException($"multiple -v options in endpoint '{endpoint}'"); } if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -v option in endpoint " + endpoint); + throw new ParseException($"no argument provided for -v option in endpoint '{endpoint}'"); } try @@ -381,7 +379,7 @@ protected override bool checkOption(string option, string argument, string endpo } catch (System.FormatException ex) { - throw new Ice.EndpointParseException("Invalid Base64 input in endpoint " + endpoint, ex); + throw new ParseException($"invalid Base64 input in endpoint '{endpoint}'", ex); } return true; @@ -391,7 +389,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -e option in endpoint " + endpoint); + throw new ParseException($"no argument provided for -e option in endpoint '{endpoint}'"); } try @@ -400,8 +398,7 @@ protected override bool checkOption(string option, string argument, string endpo } catch (Ice.VersionParseException e) { - throw new Ice.EndpointParseException("invalid encoding version `" + argument + - "' in endpoint " + endpoint + ":\n" + e.str); + throw new ParseException($"invalid encoding version '{argument}' in endpoint '{endpoint}'", e); } return true; } diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index 652dd9a8101..fe52ad44a48 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -457,9 +457,7 @@ public Reference create(string s, string propertyPrefix) if (endpoints.Count == 0) { Debug.Assert(unknownEndpoints.Count > 0); - Ice.EndpointParseException e2 = new Ice.EndpointParseException(); - e2.str = "invalid endpoint `" + unknownEndpoints[0] + "' in `" + s + "'"; - throw e2; + throw new ParseException($"invalid endpoint '{unknownEndpoints[0]}' in '{s}'"); } else if (unknownEndpoints.Count != 0 && _instance.initializationData().properties.getPropertyAsIntWithDefault( diff --git a/csharp/src/Ice/Internal/TcpEndpointI.cs b/csharp/src/Ice/Internal/TcpEndpointI.cs index f83f6add3eb..ce586d594a1 100644 --- a/csharp/src/Ice/Internal/TcpEndpointI.cs +++ b/csharp/src/Ice/Internal/TcpEndpointI.cs @@ -219,8 +219,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - throw new Ice.EndpointParseException("no argument provided for -t option in endpoint " + - endpoint); + throw new ParseException($"no argument provided for -t option in endpoint '{endpoint}'"); } if (argument == "infinite") @@ -234,16 +233,12 @@ protected override bool checkOption(string option, string argument, string endpo _timeout = int.Parse(argument, CultureInfo.InvariantCulture); if (_timeout < 1) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; + throw new ParseException($"invalid timeout value '{argument}' in endpoint {endpoint}"); } } catch (System.FormatException ex) { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid timeout value `" + argument + "' in endpoint " + endpoint; - throw e; + throw new ParseException($"invalid timeout value '{argument}' in endpoint {endpoint}", ex); } } @@ -254,8 +249,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument != null) { - throw new Ice.EndpointParseException("unexpected argument `" + argument + - "' provided for -z option in " + endpoint); + throw new ParseException($"unexpected argument '{argument}' provided for -z option in endpoint '{endpoint}'"); } _compress = true; diff --git a/csharp/src/Ice/Internal/UdpEndpointI.cs b/csharp/src/Ice/Internal/UdpEndpointI.cs index 16f67a2962a..e1b5accc494 100644 --- a/csharp/src/Ice/Internal/UdpEndpointI.cs +++ b/csharp/src/Ice/Internal/UdpEndpointI.cs @@ -162,8 +162,7 @@ public override void initWithOptions(List args, bool oaEndpoint) } else { - throw new Ice.EndpointParseException("`--interface *' not valid for proxy endpoint `" + - ToString() + "'"); + throw new ParseException($"'--interface *' not valid for proxy endpoint '{this}'"); } } } @@ -320,9 +319,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument != null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "unexpected argument `" + argument + "' provided for -c option in " + endpoint; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -c option in endpoint '{endpoint}'"); } _connect = true; @@ -331,9 +328,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument != null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "unexpected argument `" + argument + "' provided for -z option in " + endpoint; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -z option in endpoint '{endpoint}'"); } _compress = true; @@ -342,9 +337,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "no argument provided for " + option + " option in endpoint " + endpoint; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for {option} option in endpoint '{endpoint}'"); } try @@ -357,18 +350,14 @@ protected override bool checkOption(string option, string argument, string endpo } catch (Ice.VersionParseException ex) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "invalid version `" + argument + "' in endpoint " + endpoint + ":\n" + ex.str; - throw e; + throw new ParseException($"invalid version '{argument}' in endpoint '{endpoint}'", ex); } } else if (option == "--ttl") { if (argument == null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "no argument provided for --ttl option in endpoint " + endpoint; - throw e; + throw new ParseException($"no argument provided for --ttl option in endpoint '{endpoint}'"); } try @@ -377,25 +366,19 @@ protected override bool checkOption(string option, string argument, string endpo } catch (FormatException ex) { - Ice.EndpointParseException e = new Ice.EndpointParseException(ex); - e.str = "invalid TTL value `" + argument + "' in endpoint " + endpoint; - throw e; + throw new ParseException($"invalid TTL value '{argument}' in endpoint '{endpoint}'", ex); } if (_mcastTtl < 0) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "TTL value `" + argument + "' out of range in endpoint " + endpoint; - throw e; + throw new ParseException($"TTL value '{argument}' out of range in endpoint '{endpoint}'"); } } else if (option == "--interface") { if (argument == null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "no argument provided for --interface option in endpoint " + endpoint; - throw e; + throw new ParseException($"no argument provided for --interface option in endpoint '{endpoint}'"); } _mcastInterface = argument; } diff --git a/csharp/src/Ice/Internal/WSEndpoint.cs b/csharp/src/Ice/Internal/WSEndpoint.cs index 5ddb6f12577..7f2571f1d4c 100644 --- a/csharp/src/Ice/Internal/WSEndpoint.cs +++ b/csharp/src/Ice/Internal/WSEndpoint.cs @@ -309,9 +309,7 @@ protected override bool checkOption(string option, string argument, string endpo { if (argument == null) { - Ice.EndpointParseException e = new Ice.EndpointParseException(); - e.str = "no argument provided for -r option in endpoint " + endpoint + _delegate.options(); - throw e; + throw new ParseException($"no argument provided for -r option in endpoint '{endpoint}{_delegate.options()}'"); } _resource = argument; return true; diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 93f8d1f37a8..8aa28b66318 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -34,7 +34,7 @@ protected RequestFailedException( /// /// The dispatch could not find a servant for the identity carried by the request. /// -public class ObjectNotExistException : RequestFailedException +public sealed class ObjectNotExistException : RequestFailedException { public ObjectNotExistException(System.Exception? innerException = null) : base(new Identity(), "", "", innerException) @@ -55,7 +55,7 @@ public override string ice_id() /// /// The dispatch could not find a servant for the identity + facet carried by the request. /// -public class FacetNotExistException : RequestFailedException +public sealed class FacetNotExistException : RequestFailedException { public FacetNotExistException(System.Exception? innerException = null) : base(new Identity(), "", "", innerException) @@ -77,7 +77,7 @@ public override string ice_id() /// The dispatch could not find the operation carried by the request on the target servant. This is typically due /// to a mismatch in the Slice definitions, such as the client using Slice definitions newer than the server's. /// -public class OperationNotExistException : RequestFailedException +public sealed class OperationNotExistException : RequestFailedException { public OperationNotExistException(System.Exception? innerException = null) : base(new Identity(), "", "", innerException) @@ -117,7 +117,7 @@ public override string ice_id() /// The dispatch failed with a that is not one of the special marshal-able local /// exception. /// -public class UnknownLocalException : UnknownException +public sealed class UnknownLocalException : UnknownException { public UnknownLocalException(string message, LocalException? innerException = null) : base(message, innerException) @@ -134,7 +134,7 @@ public override string ice_id() /// The dispatch returned a that was not declared in the operation's exception /// specification. /// -public class UnknownUserException : UnknownException +public sealed class UnknownUserException : UnknownException { public UnknownUserException(string message) : base(message, innerException: null) @@ -146,3 +146,18 @@ public override string ice_id() return "::Ice::UnknownUserException"; } } + +/// +/// Reports a failure that occurred while parsing a string. +/// +public sealed class ParseException : LocalException +{ + public string unknown => Message; + + public ParseException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::ParseException"; +} diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index 7dce6ce5ced..8faf54eff9c 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1397,7 +1397,7 @@ private List parseEndpoints(string endpts, bool oaEndpoints) { if (endpoints.Count != 0) { - throw new EndpointParseException("invalid empty object adapter endpoint"); + throw new ParseException("invalid empty object adapter endpoint"); } break; } @@ -1447,14 +1447,14 @@ private List parseEndpoints(string endpts, bool oaEndpoints) if (end == beg) { - throw new EndpointParseException("invalid empty object adapter endpoint"); + throw new ParseException("invalid empty object adapter endpoint"); } string s = endpts.Substring(beg, (end) - (beg)); EndpointI endp = _instance.endpointFactoryManager().create(s, oaEndpoints); if (endp is null) { - throw new EndpointParseException("invalid object adapter endpoint `" + s + "'"); + throw new ParseException($"invalid object adapter endpoint {s}'"); } endpoints.Add(endp); diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 9952ddb356f..4523950667f 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -383,49 +383,6 @@ public override string ice_id() } } -/// -/// This exception is raised if there was an error while parsing an endpoint. -/// -public class EndpointParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointParseException() - { - _initDM(); - } - - public EndpointParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointParseException(string str) - { - _initDM(str); - } - - public EndpointParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::EndpointParseException"; - } -} - /// /// This exception is raised if there was an error while parsing an endpoint selection type. /// diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 66625e2917e..78de33c3d1f 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -109,7 +109,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("test:"); // Missing endpoint. test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -230,7 +230,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("test:tcp@adapterId"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } // This is an unknown endpoint warning, not a parse exception. @@ -240,7 +240,7 @@ public class AllTests : global::Test.AllTests // b1 = communicator.stringToProxy("test -f the:facet:tcp"); // test(false); //} - //catch(Ice.EndpointParseException) + //catch(ParseException) //{ //} try @@ -248,7 +248,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("test: :tcp"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -260,7 +260,7 @@ public class AllTests : global::Test.AllTests communicator.createObjectAdapterWithEndpoints("BadAdapter", " : "); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -269,7 +269,7 @@ public class AllTests : global::Test.AllTests communicator.createObjectAdapterWithEndpoints("BadAdapter", "tcp: "); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -278,7 +278,7 @@ public class AllTests : global::Test.AllTests communicator.createObjectAdapterWithEndpoints("BadAdapter", ":tcp"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -927,7 +927,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 99 -v abcd -x abc"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -937,7 +937,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -947,7 +947,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 1 -t 1 -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -957,7 +957,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 1 -v abcd -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -967,7 +967,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -977,7 +977,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 1"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -987,7 +987,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -997,7 +997,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 1 -v"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -1007,7 +1007,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t x -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -1017,7 +1017,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t -1 -v abcd"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -1027,7 +1027,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 99 -v x?c"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } @@ -1037,7 +1037,7 @@ public class AllTests : global::Test.AllTests communicator.stringToProxy("id:opaque -t 99 -v xc"); test(false); } - catch (Ice.EndpointParseException) + catch (ParseException) { } From 31fc9b30a91cb40045dc0361f9003d11c8d50df0 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 16:50:57 -0400 Subject: [PATCH 04/21] Remove ProxyParseException --- csharp/src/Ice/Internal/ReferenceFactory.cs | 94 ++++++--------------- csharp/src/Ice/ObjectAdapter.cs | 2 +- csharp/src/Ice/OldLocalExceptions.cs | 43 ---------- csharp/src/Ice/Proxy.cs | 4 +- csharp/test/Ice/proxy/AllTests.cs | 14 +-- 5 files changed, 35 insertions(+), 122 deletions(-) diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index fe52ad44a48..d4a609c30e4 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -85,9 +85,7 @@ public Reference create(string s, string propertyPrefix) beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end); if (beg == -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "no non-whitespace characters found in `" + s + "'"; - throw e; + throw new ParseException($"no non-whitespace characters found in proxy string '{s}'"); } // @@ -98,9 +96,7 @@ public Reference create(string s, string propertyPrefix) end = Ice.UtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "mismatched quotes around identity in `" + s + "'"; - throw e; + throw new ParseException($"mismatched quotes around identity in proxy string '{s}'"); } else if (end == 0) { @@ -120,9 +116,7 @@ public Reference create(string s, string propertyPrefix) if (beg == end) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "no identity in `" + s + "'"; - throw e; + throw new ParseException($"no identity in proxy string '{s}'"); } // @@ -150,9 +144,7 @@ public Reference create(string s, string propertyPrefix) // else if (Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "invalid characters after identity in `" + s + "'"; - throw e; + throw new ParseException($"invalid characters after identity in proxy string '{s}'"); } else { @@ -194,9 +186,7 @@ public Reference create(string s, string propertyPrefix) string option = s.Substring(beg, end - beg); if (option.Length != 2 || option[0] != '-') { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "expected a proxy option but found `" + option + "' in `" + s + "'"; - throw e; + throw new ParseException($"expected a proxy option but found '{option}' in proxy string '{s}'"); } // @@ -215,9 +205,7 @@ public Reference create(string s, string propertyPrefix) end = Ice.UtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "mismatched quotes around value for " + option + " option in `" + s + "'"; - throw e; + throw new ParseException($"mismatched quotes around value for '{option}' option in proxy string '{s}'"); } else if (end == 0) { @@ -247,9 +235,7 @@ public Reference create(string s, string propertyPrefix) { if (argument == null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "no argument provided for -f option in `" + s + "'"; - throw e; + throw new ParseException($"no argument provided for -f option in proxy string '{s}'"); } try @@ -258,9 +244,7 @@ public Reference create(string s, string propertyPrefix) } catch (ArgumentException argEx) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "invalid facet in `" + s + "': " + argEx.Message; - throw e; + throw new ParseException($"invalid facet in proxy string '{s}'", argEx); } break; } @@ -269,9 +253,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -t option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -t option in proxy string '{s}'"); } mode = Reference.Mode.ModeTwoway; break; @@ -281,9 +263,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -o option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -o option in proxy string '{s}'"); } mode = Reference.Mode.ModeOneway; break; @@ -293,9 +273,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -O option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -O option in proxy string '{s}'"); } mode = Reference.Mode.ModeBatchOneway; break; @@ -305,9 +283,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -d option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -d option in proxy string '{s}'"); } mode = Reference.Mode.ModeDatagram; break; @@ -317,9 +293,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -D option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -D option in proxy string '{s}'"); } mode = Reference.Mode.ModeBatchDatagram; break; @@ -329,9 +303,7 @@ public Reference create(string s, string propertyPrefix) { if (argument != null) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unexpected argument `" + argument + "' provided for -s option in `" + s + "'"; - throw e; + throw new ParseException($"unexpected argument '{argument}' provided for -s option in proxy string '{s}'"); } secure = true; break; @@ -341,7 +313,7 @@ public Reference create(string s, string propertyPrefix) { if (argument == null) { - throw new Ice.ProxyParseException("no argument provided for -e option `" + s + "'"); + throw new ParseException($"no argument provided for -e option in proxy string '{s}'"); } try @@ -350,8 +322,7 @@ public Reference create(string s, string propertyPrefix) } catch (Ice.VersionParseException e) { - throw new Ice.ProxyParseException("invalid encoding version `" + argument + "' in `" + s + - "':\n" + e.str); + throw new ParseException($"invalid encoding version '{argument}' in proxy string '{s}'", e); } break; } @@ -360,7 +331,7 @@ public Reference create(string s, string propertyPrefix) { if (argument == null) { - throw new Ice.ProxyParseException("no argument provided for -p option `" + s + "'"); + throw new ParseException($"no argument provided for -p option in proxy string '{s}'"); } try @@ -369,17 +340,14 @@ public Reference create(string s, string propertyPrefix) } catch (Ice.VersionParseException e) { - throw new Ice.ProxyParseException("invalid protocol version `" + argument + "' in `" + s + - "':\n" + e.str); + throw new ParseException($"invalid protocol version '{argument}' in proxy string '{s}'", e); } break; } default: { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "unknown option `" + option + "' in `" + s + "'"; - throw e; + throw new ParseException($"unknown option '{option}' in proxy string '{s}'"); } } } @@ -482,18 +450,14 @@ public Reference create(string s, string propertyPrefix) beg = Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, beg + 1); if (beg == -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "missing adapter id in `" + s + "'"; - throw e; + throw new ParseException($"missing adapter ID in proxy string '{s}'"); } string adapterstr = null; end = Ice.UtilInternal.StringUtil.checkQuote(s, beg); if (end == -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "mismatched quotes around adapter id in `" + s + "'"; - throw e; + throw new ParseException($"mismatched quotes around adapter ID in proxy string '{s}'"); } else if (end == 0) { @@ -513,9 +477,7 @@ public Reference create(string s, string propertyPrefix) if (end != s.Length && Ice.UtilInternal.StringUtil.findFirstNotOf(s, delim, end) != -1) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "invalid trailing characters after `" + s.Substring(0, end + 1) + "' in `" + s + "'"; - throw e; + throw new ParseException($"invalid characters after adapter ID in proxy string '{s}'"); } try @@ -524,22 +486,16 @@ public Reference create(string s, string propertyPrefix) } catch (ArgumentException argEx) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "invalid adapter id in `" + s + "': " + argEx.Message; - throw e; + throw new ParseException($"invalid adapter ID in proxy string '{s}'", argEx); } if (adapter.Length == 0) { - Ice.ProxyParseException e = new Ice.ProxyParseException(); - e.str = "empty adapter id in `" + s + "'"; - throw e; + throw new ParseException($"empty adapter ID in proxy string '{s}'"); } return create(ident, facet, mode, secure, protocol, encoding, null, adapter, propertyPrefix); } - Ice.ProxyParseException ex = new Ice.ProxyParseException(); - ex.str = "malformed proxy `" + s + "'"; - throw ex; + throw new ParseException($"malformed proxy string '{s}'"); } public Reference create(Ice.Identity ident, Ice.InputStream s) diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index 8faf54eff9c..a8baa5e2afd 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1215,7 +1215,7 @@ internal ObjectAdapter( { _reference = _instance.referenceFactory().create("dummy " + proxyOptions, ""); } - catch (ProxyParseException) + catch (ParseException) { InitializationException ex = new InitializationException(); ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'"; diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 4523950667f..074da7faa2a 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -512,49 +512,6 @@ public override string ice_id() } } -/// -/// This exception is raised if there was an error while parsing a stringified proxy. -/// -public class ProxyParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public ProxyParseException() - { - _initDM(); - } - - public ProxyParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public ProxyParseException(string str) - { - _initDM(str); - } - - public ProxyParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::ProxyParseException"; - } -} - /// /// This exception is raised if an illegal identity is encountered. /// diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index e0c66bc08d6..9c263a0d7f0 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -1806,7 +1806,7 @@ public class ObjectPrxHelper : ObjectPrxHelperBase /// The communicator of the new proxy. /// The string representation of the proxy. /// The new proxy. - /// Thrown when is not a valid proxy string. + /// Thrown when is not a valid proxy string. /// public static ObjectPrx createProxy(Communicator communicator, string proxyString) { @@ -1814,7 +1814,7 @@ public static ObjectPrx createProxy(Communicator communicator, string proxyStrin return reference is not null ? new ObjectPrxHelper(reference) : - throw new ProxyParseException("Invalid empty proxy string."); + throw new ParseException("Invalid empty proxy string."); } /// Casts a proxy to {@link ObjectPrx}. This call contacts diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 78de33c3d1f..6451d766b11 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -36,7 +36,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("\"test -f facet'"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("\"test -f facet\""); @@ -53,7 +53,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("test test"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("test\\040test"); @@ -101,7 +101,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("\"\" test"); // Invalid trailing characters. test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } try @@ -121,7 +121,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("id@adapter test"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("category/test@adapter"); @@ -160,7 +160,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("id -f \"facet x"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } try @@ -168,7 +168,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("id -f \'facet x"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("test -f facet:tcp"); @@ -191,7 +191,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("test -f facet@test @test"); test(false); } - catch (Ice.ProxyParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("test"); From 860465f87d7aa599a84b2d0d2777336c488a6d22 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 17:02:24 -0400 Subject: [PATCH 05/21] Remove remaining XxxParseException --- .../src/Ice/Internal/DefaultsAndOverrides.cs | 4 +- csharp/src/Ice/Internal/OpaqueEndpointI.cs | 2 +- csharp/src/Ice/Internal/ReferenceFactory.cs | 9 +- csharp/src/Ice/Internal/UdpEndpointI.cs | 2 +- csharp/src/Ice/OldLocalExceptions.cs | 129 ------------------ csharp/src/Ice/Util.cs | 24 ++-- csharp/test/Ice/proxy/AllTests.cs | 6 +- 7 files changed, 18 insertions(+), 158 deletions(-) diff --git a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs index b3217ebce5d..a5487682522 100644 --- a/csharp/src/Ice/Internal/DefaultsAndOverrides.cs +++ b/csharp/src/Ice/Internal/DefaultsAndOverrides.cs @@ -82,9 +82,7 @@ internal DefaultsAndOverrides(Ice.Properties properties, Ice.Logger logger) } else { - Ice.EndpointSelectionTypeParseException ex = new Ice.EndpointSelectionTypeParseException(); - ex.str = "illegal value `" + val + "'; expected `Random' or `Ordered'"; - throw ex; + throw new ParseException($"illegal value '{val}' in property Ice.Default.EndpointSelection; expected 'Random' or 'Ordered'"); } defaultLocatorCacheTimeout = properties.getIcePropertyAsInt("Ice.Default.LocatorCacheTimeout"); diff --git a/csharp/src/Ice/Internal/OpaqueEndpointI.cs b/csharp/src/Ice/Internal/OpaqueEndpointI.cs index 9e0bb1135c8..9a2285e9976 100644 --- a/csharp/src/Ice/Internal/OpaqueEndpointI.cs +++ b/csharp/src/Ice/Internal/OpaqueEndpointI.cs @@ -396,7 +396,7 @@ protected override bool checkOption(string option, string argument, string endpo { _rawEncoding = Ice.Util.stringToEncodingVersion(argument); } - catch (Ice.VersionParseException e) + catch (ParseException e) { throw new ParseException($"invalid encoding version '{argument}' in endpoint '{endpoint}'", e); } diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index d4a609c30e4..fe81daedd2c 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -120,7 +120,7 @@ public Reference create(string s, string propertyPrefix) } // - // Parsing the identity may raise IdentityParseException. + // Parsing the identity may raise ParseException. // Ice.Identity ident = Ice.Util.stringToIdentity(idstr); @@ -320,7 +320,7 @@ public Reference create(string s, string propertyPrefix) { encoding = Ice.Util.stringToEncodingVersion(argument); } - catch (Ice.VersionParseException e) + catch (ParseException e) { throw new ParseException($"invalid encoding version '{argument}' in proxy string '{s}'", e); } @@ -338,7 +338,7 @@ public Reference create(string s, string propertyPrefix) { protocol = Ice.Util.stringToProtocolVersion(argument); } - catch (Ice.VersionParseException e) + catch (ParseException e) { throw new ParseException($"invalid protocol version '{argument}' in proxy string '{s}'", e); } @@ -785,8 +785,7 @@ private Reference create(Ice.Identity ident, } else { - throw new Ice.EndpointSelectionTypeParseException("illegal value `" + type + - "'; expected `Random' or `Ordered'"); + throw new ParseException($"illegal value '{type}' in property '{property}'; expected 'Random' or 'Ordered'"); } } diff --git a/csharp/src/Ice/Internal/UdpEndpointI.cs b/csharp/src/Ice/Internal/UdpEndpointI.cs index e1b5accc494..3337ec66be7 100644 --- a/csharp/src/Ice/Internal/UdpEndpointI.cs +++ b/csharp/src/Ice/Internal/UdpEndpointI.cs @@ -348,7 +348,7 @@ protected override bool checkOption(string option, string argument, string endpo instance_.logger().warning("deprecated udp endpoint option: " + option); } } - catch (Ice.VersionParseException ex) + catch (ParseException ex) { throw new ParseException($"invalid version '{argument}' in endpoint '{endpoint}'", ex); } diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 074da7faa2a..c86eb63c77e 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -383,135 +383,6 @@ public override string ice_id() } } -/// -/// This exception is raised if there was an error while parsing an endpoint selection type. -/// -public class EndpointSelectionTypeParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public EndpointSelectionTypeParseException() - { - _initDM(); - } - - public EndpointSelectionTypeParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public EndpointSelectionTypeParseException(string str) - { - _initDM(str); - } - - public EndpointSelectionTypeParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::EndpointSelectionTypeParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a version. -/// -public class VersionParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public VersionParseException() - { - _initDM(); - } - - public VersionParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public VersionParseException(string str) - { - _initDM(str); - } - - public VersionParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::VersionParseException"; - } -} - -/// -/// This exception is raised if there was an error while parsing a stringified identity. -/// -public class IdentityParseException : LocalException -{ - public string str; - - private void _initDM() - { - this.str = ""; - } - - public IdentityParseException() - { - _initDM(); - } - - public IdentityParseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string str) - { - this.str = str; - } - - public IdentityParseException(string str) - { - _initDM(str); - } - - public IdentityParseException(string str, System.Exception ex) : base(ex) - { - _initDM(str); - } - - public override string ice_id() - { - return "::Ice::IdentityParseException"; - } -} - /// /// This exception is raised if an illegal identity is encountered. /// diff --git a/csharp/src/Ice/Util.cs b/csharp/src/Ice/Util.cs index adfb63c07fe..c174f687cb3 100644 --- a/csharp/src/Ice/Util.cs +++ b/csharp/src/Ice/Util.cs @@ -206,9 +206,7 @@ public static Identity stringToIdentity(string s) // // Extra unescaped slash found. // - IdentityParseException ex = new IdentityParseException(); - ex.str = "unescaped backslash in identity `" + s + "'"; - throw ex; + throw new ParseException($"unescaped backslash in identity string '{s}'"); } } pos++; @@ -223,9 +221,7 @@ public static Identity stringToIdentity(string s) } catch (ArgumentException e) { - IdentityParseException ex = new IdentityParseException(); - ex.str = "invalid identity name `" + s + "': " + e.Message; - throw ex; + throw new ParseException($"invalid name in identity string '{s}'", e); } } else @@ -236,9 +232,7 @@ public static Identity stringToIdentity(string s) } catch (ArgumentException e) { - IdentityParseException ex = new IdentityParseException(); - ex.str = "invalid category in identity `" + s + "': " + e.Message; - throw ex; + throw new ParseException($"invalid category in identity string '{s}'", e); } if (slash + 1 < s.Length) { @@ -248,9 +242,7 @@ public static Identity stringToIdentity(string s) } catch (ArgumentException e) { - IdentityParseException ex = new IdentityParseException(); - ex.str = "invalid name in identity `" + s + "': " + e.Message; - throw ex; + throw new ParseException($"invalid name in identity string '{s}'", e); } } else @@ -481,7 +473,7 @@ static private void stringToMajorMinor(string str, out byte major, out byte mino int pos = str.IndexOf('.'); if (pos == -1) { - throw new VersionParseException("malformed version value `" + str + "'"); + throw new ParseException($"malformed version value in '{str}'"); } string majStr = str.Substring(0, (pos) - (0)); @@ -493,14 +485,14 @@ static private void stringToMajorMinor(string str, out byte major, out byte mino majVersion = int.Parse(majStr, CultureInfo.InvariantCulture); minVersion = int.Parse(minStr, CultureInfo.InvariantCulture); } - catch (FormatException) + catch (FormatException ex) { - throw new VersionParseException("invalid version value `" + str + "'"); + throw new ParseException($"invalid version value in '{str}'", ex); } if (majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255) { - throw new VersionParseException("range error in version `" + str + "'"); + throw new ParseException($"range error in version '{str}'"); } major = (byte)majVersion; diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 6451d766b11..48a2f962dd8 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -63,7 +63,7 @@ public class AllTests : global::Test.AllTests b1 = communicator.stringToProxy("test\\777"); test(false); } - catch (Ice.IdentityParseException) + catch (ParseException) { } b1 = communicator.stringToProxy("test\\40test"); @@ -309,7 +309,7 @@ public class AllTests : global::Test.AllTests id = Ice.Util.stringToIdentity("xx\01FooBar"); test(false); } - catch (Ice.IdentityParseException) + catch (ParseException) { } @@ -319,7 +319,7 @@ public class AllTests : global::Test.AllTests id = Ice.Util.stringToIdentity("xx\\ud911"); test(false); } - catch (Ice.IdentityParseException) + catch (ParseException) { } From df9c5f698a03c82815644ff48019c4357ad5607a Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sat, 22 Jun 2024 17:19:01 -0400 Subject: [PATCH 06/21] Remove Illegal exceptions --- CHANGELOG-3.8.md | 19 +++-- csharp/src/Ice/Internal/Instance.cs | 2 +- csharp/src/Ice/Internal/ReferenceFactory.cs | 4 +- csharp/src/Ice/LocalExceptions.cs | 30 ++----- csharp/src/Ice/ObjectAdapter.cs | 14 +--- csharp/src/Ice/OldLocalExceptions.cs | 86 --------------------- csharp/src/Ice/Proxy.cs | 2 +- csharp/test/Ice/exceptions/AllTests.cs | 5 +- 8 files changed, 23 insertions(+), 139 deletions(-) diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index a3aa41e3efd..3f9afdd5757 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -59,19 +59,18 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG property `AdapterName.Connection.CloseTimeout`. - Consolidate and refactor the exceptions derived from LocalException. - | Local exception in Ice 3.7 | Replacement | - |----------------------------------|-----------------------| - | EndpointParseException | ParseException | + | Local exception in Ice 3.7 | Replacement | + |-------------------------------------|-----------------------| + | EndpointParseException | ParseException | | EndpointSelectionTypeParseException | ParseException | - | IllegalIdentityException | Argument exception from standard library | - | IllegalServantException | Argument exception from standard library | - | IdentityParseException | ParseException | - | ProxyParseException | ParseException | - | VersionParseException | ParseException | - | + | IllegalIdentityException | ArgumentException (C#) | + | IllegalServantException | ArgumentNullException (C#) | + | IdentityParseException | ParseException | + | ProxyParseException | ParseException | + | VersionParseException | ParseException | New exceptions:\ - ConnectionIdleException, + ConnectionIdleException, ParseException ## Slice Language Changes diff --git a/csharp/src/Ice/Internal/Instance.cs b/csharp/src/Ice/Internal/Instance.cs index 5d686f65fa7..b9bbe76f7d7 100644 --- a/csharp/src/Ice/Internal/Instance.cs +++ b/csharp/src/Ice/Internal/Instance.cs @@ -335,7 +335,7 @@ public Ice.ObjectPrx createAdmin(Ice.ObjectAdapter adminAdapter, Ice.Identity ad if (adminIdentity == null || adminIdentity.name.Length == 0) { - throw new Ice.IllegalIdentityException(adminIdentity); + throw new ArgumentException("The admin identity is not valid", nameof(adminIdentity)); } if (_adminAdapter != null) diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index fe81daedd2c..da359ad5670 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -132,9 +132,7 @@ public Reference create(string s, string propertyPrefix) // if (ident.category.Length > 0) { - Ice.IllegalIdentityException e = new Ice.IllegalIdentityException(); - e.id = ident; - throw e; + throw new ParseException("The category of a null Ice object identity must be empty."); } // // Treat a stringified proxy containing two double diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 8aa28b66318..85f99da9184 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -46,10 +46,7 @@ public ObjectNotExistException(Identity id, string facet, string operation, Syst { } - public override string ice_id() - { - return "::Ice::ObjectNotExistException"; - } + public override string ice_id() => "::Ice::ObjectNotExistException"; } /// @@ -67,10 +64,7 @@ public FacetNotExistException(Identity id, string facet, string operation, Syste { } - public override string ice_id() - { - return "::Ice::FacetNotExistException"; - } + public override string ice_id() => "::Ice::FacetNotExistException"; } /// @@ -89,10 +83,7 @@ public OperationNotExistException(Identity id, string facet, string operation, S { } - public override string ice_id() - { - return "::Ice::OperationNotExistException"; - } + public override string ice_id() => "::Ice::OperationNotExistException"; } /// @@ -107,10 +98,7 @@ public UnknownException(string message, System.Exception? innerException = null) { } - public override string ice_id() - { - return "::Ice::UnknownException"; - } + public override string ice_id() => "::Ice::UnknownException"; } /// @@ -124,10 +112,7 @@ public UnknownLocalException(string message, LocalException? innerException = nu { } - public override string ice_id() - { - return "::Ice::UnknownLocalException"; - } + public override string ice_id() => "::Ice::UnknownLocalException"; } /// @@ -141,10 +126,7 @@ public UnknownUserException(string message) { } - public override string ice_id() - { - return "::Ice::UnknownUserException"; - } + public override string ice_id() => "::Ice::UnknownUserException"; } /// diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index a8baa5e2afd..6dc00c15d1a 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -436,7 +436,7 @@ public ObjectPrx addFacet(Object obj, Identity ident, string facet) { checkForDeactivation(); checkIdentity(ident); - checkServant(obj); + ArgumentNullException.ThrowIfNull(obj); // // Create a copy of the Identity argument, in case the caller @@ -501,7 +501,7 @@ public ObjectPrx addFacetWithUUID(Object servant, string facet) /// public void addDefaultServant(Ice.Object servant, string category) { - checkServant(servant); + ArgumentNullException.ThrowIfNull(servant); lock (this) { @@ -1333,7 +1333,7 @@ internal static void checkIdentity(Identity ident) { if (ident.name.Length == 0) { - throw new IllegalIdentityException(ident); + throw new ArgumentException("The name of an Ice object identity cannot be empty.", nameof(ident)); } } @@ -1374,14 +1374,6 @@ private void checkForDeactivation() } } - private static void checkServant(Object servant) - { - if (servant is null) - { - throw new IllegalServantException("cannot add null servant to Object Adapter"); - } - } - private List parseEndpoints(string endpts, bool oaEndpoints) { int beg; diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index c86eb63c77e..84e64ed4a4c 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -383,92 +383,6 @@ public override string ice_id() } } -/// -/// This exception is raised if an illegal identity is encountered. -/// -public class IllegalIdentityException : LocalException -{ - public Identity id; - - private void _initDM() - { - this.id = new Identity(); - } - - public IllegalIdentityException() - { - _initDM(); - } - - public IllegalIdentityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(Identity id) - { - this.id = id; - } - - public IllegalIdentityException(Identity id) - { - _initDM(id); - } - - public IllegalIdentityException(Identity id, System.Exception ex) : base(ex) - { - _initDM(id); - } - - public override string ice_id() - { - return "::Ice::IllegalIdentityException"; - } -} - -/// -/// This exception is raised to reject an illegal servant (typically a null servant). -/// -public class IllegalServantException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public IllegalServantException() - { - _initDM(); - } - - public IllegalServantException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public IllegalServantException(string reason) - { - _initDM(reason); - } - - public IllegalServantException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::IllegalServantException"; - } -} - /// /// This exception is raised if a system error occurred in the server or client process. /// There are many possible causes diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index 9c263a0d7f0..adf21a27764 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -853,7 +853,7 @@ public ObjectPrx ice_identity(Identity newIdentity) { if (newIdentity.name.Length == 0) { - throw new IllegalIdentityException(); + throw new ArgumentException("The name of an Ice object identity cannot be empty.", nameof(newIdentity)); } if (newIdentity == _reference.getIdentity()) { diff --git a/csharp/test/Ice/exceptions/AllTests.cs b/csharp/test/Ice/exceptions/AllTests.cs index 80d3aab0adb..7106d34cd54 100644 --- a/csharp/test/Ice/exceptions/AllTests.cs +++ b/csharp/test/Ice/exceptions/AllTests.cs @@ -108,9 +108,8 @@ public virtual void called() adapter.add(obj, Util.stringToIdentity("")); test(false); } - catch (IllegalIdentityException e) + catch (ArgumentException) { - test(e.id.name.Length == 0); } try @@ -118,7 +117,7 @@ public virtual void called() adapter.add(null, Util.stringToIdentity("x")); test(false); } - catch (IllegalServantException) + catch (ArgumentNullException) { } From 875fe1bac331e3042f5e34aa7c27fb87c829b903 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 08:52:21 -0400 Subject: [PATCH 07/21] Fix ProtocolException --- CHANGELOG-3.8.md | 20 +++++----- csharp/src/Ice/ConnectionI.cs | 12 +++--- csharp/src/Ice/InputStream.cs | 9 +---- csharp/src/Ice/Internal/BZip2.cs | 8 +--- csharp/src/Ice/Internal/Buffer.cs | 4 +- csharp/src/Ice/LocalExceptions.cs | 26 ++++++++++++ csharp/src/Ice/Object.cs | 5 +-- csharp/src/Ice/OldLocalExceptions.cs | 59 +++------------------------- 8 files changed, 54 insertions(+), 89 deletions(-) diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index 3f9afdd5757..4870552c568 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -59,18 +59,18 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG property `AdapterName.Connection.CloseTimeout`. - Consolidate and refactor the exceptions derived from LocalException. - | Local exception in Ice 3.7 | Replacement | - |-------------------------------------|-----------------------| - | EndpointParseException | ParseException | - | EndpointSelectionTypeParseException | ParseException | - | IllegalIdentityException | ArgumentException (C#) | + | Local exception in Ice 3.7 | Replacement | + |-------------------------------------|----------------------------| + | EndpointParseException | ParseException | + | EndpointSelectionTypeParseException | ParseException | + | IllegalIdentityException | ArgumentException (C#) | | IllegalServantException | ArgumentNullException (C#) | - | IdentityParseException | ParseException | - | ProxyParseException | ParseException | - | VersionParseException | ParseException | + | IdentityParseException | ParseException | + | ProxyParseException | ParseException | + | VersionParseException | ParseException | - New exceptions:\ - ConnectionIdleException, ParseException + New local exceptions:\ + ConnectionCloseException, ConnectionIdleException, ParseException ## Slice Language Changes diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index b9d4adacf85..ced4d0851b9 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -1507,16 +1507,16 @@ internal void idleCheck(TimeSpan idleTimeout) { if (isActiveOrHolding()) { + int idleTimeoutInSeconds = (int)idleTimeout.TotalSeconds; + if (_instance.traceLevels().network >= 1) { - int idleTimeoutInSeconds = (int)idleTimeout.TotalSeconds; - _instance.initializationData().logger.trace( _instance.traceLevels().networkCat, $"connection aborted by the idle check because it did not receive any bytes for {idleTimeoutInSeconds}s\n{_transceiver.toDetailedString()}"); } - setState(StateClosed, new ConnectionIdleException()); + setState(StateClosed, new ConnectionIdleException($"Connection aborted by the idle check because it did not receive any bytes for {idleTimeoutInSeconds}s.")); } // else nothing to do } @@ -2613,9 +2613,9 @@ private void inactivityCheck(System.Threading.Timer inactivityTimer) if (_state == StateActive) { - // TODO: fix LocalException to accept a message - // "connection closed because it remained inactive for longer than the inactivity timeout" - setState(StateClosing, new ConnectionClosedException()); + setState( + StateClosing, + new ConnectionClosedException("Connection closed because it remained inactive for longer than the inactivity timeout.")); } } // Else this timer was already canceled and disposed. Nothing to do. diff --git a/csharp/src/Ice/InputStream.cs b/csharp/src/Ice/InputStream.cs index 88375acc396..6d087e4f35d 100644 --- a/csharp/src/Ice/InputStream.cs +++ b/csharp/src/Ice/InputStream.cs @@ -3000,18 +3000,13 @@ internal override void throwException(UserExceptionFactory? factory) { startSlice(); } - catch (UnmarshalOutOfBoundsException ex) + catch (UnmarshalOutOfBoundsException) { - // // An oversight in the 1.0 encoding means there is no marker to indicate // the last slice of an exception. As a result, we just try to read the // next type ID, which raises UnmarshalOutOfBoundsException when the // input buffer underflows. - // - // Set the reason member to a more helpful message. - // - ex.reason = "unknown exception type `" + mostDerivedId + "'"; - throw; + throw new MarshalException($"unknown exception type '{mostDerivedId}'"); } } } diff --git a/csharp/src/Ice/Internal/BZip2.cs b/csharp/src/Ice/Internal/BZip2.cs index b3b65fd2672..1a9d9d37bb7 100644 --- a/csharp/src/Ice/Internal/BZip2.cs +++ b/csharp/src/Ice/Internal/BZip2.cs @@ -316,9 +316,7 @@ public static Buffer compress(Buffer buf, int headerSize, int compressionLevel) } else if (rc < 0) { - Ice.CompressionException ex = new Ice.CompressionException("BZ2_bzBuffToBuffCompress failed"); - ex.reason = getBZ2Error(rc); - throw ex; + throw new CompressionException($"BZ2_bzBuffToBuffCompress failed: {getBZ2Error(rc)}"); } // @@ -377,9 +375,7 @@ public static Buffer uncompress(Buffer buf, int headerSize, int messageSizeMax) int rc = _decompressBuffer(uncompressed, ref uncompressedLen, compressed, compressedLen, 0, 0); if (rc < 0) { - Ice.CompressionException ex = new Ice.CompressionException("BZ2_bzBuffToBuffDecompress failed"); - ex.reason = getBZ2Error(rc); - throw ex; + throw new CompressionException($"BZ2_bzBuffToBuffDecompress failed: {getBZ2Error(rc)}"); } Buffer r = new Buffer(); diff --git a/csharp/src/Ice/Internal/Buffer.cs b/csharp/src/Ice/Internal/Buffer.cs index 0d71c0ddf5e..6dd7f85a30b 100644 --- a/csharp/src/Ice/Internal/Buffer.cs +++ b/csharp/src/Ice/Internal/Buffer.cs @@ -191,9 +191,7 @@ private void reserve(int n) catch (System.Exception ex) { _capacity = b.capacity(); // Restore the previous capacity. - Ice.MarshalException e = new Ice.MarshalException(ex); - e.reason = "unexpected exception while trying to allocate a ByteBuffer:\n" + ex; - throw e; + throw new MarshalException("unexpected exception while trying to allocate a ByteBuffer", ex); } finally { diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 85f99da9184..55efd853868 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -129,6 +129,32 @@ public UnknownUserException(string message) public override string ice_id() => "::Ice::UnknownUserException"; } +/// +/// This exception indicates that a connection was closed gracefully. +/// +public class ConnectionClosedException : LocalException +{ + public ConnectionClosedException(string message) + : base(message, innerException: null) + { + } + + public override string ice_id() => "::Ice::ConnectionClosedException"; +} + +/// +/// This exception indicates that a connection was aborted by the idle check. +/// +public class ConnectionIdleException : LocalException +{ + public ConnectionIdleException(string message) + : base(message, innerException: null) + { + } + + public override string ice_id() => "::Ice::ConnectionIdleException"; +} + /// /// Reports a failure that occurred while parsing a string. /// diff --git a/csharp/src/Ice/Object.cs b/csharp/src/Ice/Object.cs index ddc00aa8e08..c78ea27298a 100644 --- a/csharp/src/Ice/Object.cs +++ b/csharp/src/Ice/Object.cs @@ -172,10 +172,7 @@ public static void iceCheckMode(OperationMode expected, OperationMode received) } else { - MarshalException ex = new MarshalException(); - ex.reason = "unexpected operation mode. expected = " + operationModeToString(expected) + - " received = " + operationModeToString(received); - throw ex; + throw new MarshalException($"unexpected operation mode: expected = {operationModeToString(expected)} received = {operationModeToString(received)}"); } } } diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 84e64ed4a4c..26689369a6c 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -624,30 +624,6 @@ public override string ice_id() } } -/// -/// This exception indicates that a connection was closed gracefully. -/// -public class ConnectionClosedException : LocalException -{ - public ConnectionClosedException() - { - } - - public override string ice_id() => "::Ice::ConnectionClosedException"; -} - -/// -/// This exception indicates that a connection was aborted by the idle check. -/// -public class ConnectionIdleException : LocalException -{ - public ConnectionIdleException() - { - } - - public override string ice_id() => "::Ice::ConnectionIdleException"; -} - /// This exception indicates a timeout condition. public class TimeoutException : LocalException { @@ -744,42 +720,19 @@ public override string ice_id() /// public class ProtocolException : LocalException { - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public ProtocolException() - { - _initDM(); - } - - public ProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } + public string reason => Message; - private void _initDM(string reason) - { - this.reason = reason; - } - - public ProtocolException(string reason) + public ProtocolException(string message = null, System.Exception innerException = null) + : base(message, innerException) { - _initDM(reason); } - public ProtocolException(string reason, System.Exception ex) : base(ex) + public ProtocolException(System.Exception innerException) + : this(message: null, innerException) { - _initDM(reason); } - public override string ice_id() - { - return "::Ice::ProtocolException"; - } + public override string ice_id() => "::Ice::ProtocolException"; } /// From 822d2db9a76126274489953d13fc52fd43ff3447 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 10:03:35 -0400 Subject: [PATCH 08/21] Removed exceptions derived from MarshalException --- CHANGELOG-3.8.md | 8 + csharp/src/Ice/ConnectionI.cs | 8 +- csharp/src/Ice/IncomingRequest.cs | 2 +- csharp/src/Ice/InputStream.cs | 124 +++++----- csharp/src/Ice/Internal/Ex.cs | 19 +- csharp/src/Ice/Internal/OutgoingAsync.cs | 2 +- csharp/src/Ice/Internal/ReferenceFactory.cs | 4 +- .../src/Ice/Internal/RequestHandlerCache.cs | 5 +- csharp/src/Ice/Internal/WSTransceiver.cs | 10 +- csharp/src/Ice/LocalExceptions.cs | 13 + csharp/src/Ice/OldLocalExceptions.cs | 229 ------------------ csharp/src/Ice/OutputStream.cs | 2 +- csharp/src/Ice/ValueFactory.cs | 4 +- csharp/test/Ice/exceptions/AllTests.cs | 7 +- csharp/test/Ice/objects/AllTests.cs | 6 +- csharp/test/Ice/operations/BatchOneways.cs | 2 +- csharp/test/Ice/slicing/objects/AllTests.cs | 15 +- csharp/test/Ice/stream/AllTests.cs | 2 +- 18 files changed, 121 insertions(+), 341 deletions(-) diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index 4870552c568..f46b449aac1 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -61,14 +61,22 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG - Consolidate and refactor the exceptions derived from LocalException. | Local exception in Ice 3.7 | Replacement | |-------------------------------------|----------------------------| + | EncapsulationException | MarshalException (base) | | EndpointParseException | ParseException | | EndpointSelectionTypeParseException | ParseException | | IllegalIdentityException | ArgumentException (C#) | | IllegalServantException | ArgumentNullException (C#) | | IdentityParseException | ParseException | + | MemoryLimitException | MarshalException (base) | + | NoValueFactoryException | MarshalException (base) | | ProxyParseException | ParseException | + | ProxyUnmarshalException | MarshalException (base) | + | UnexpectedObjectException | MarshalException (base) | + | UnmarshalOutOfBoundsException | MarshalException (base) | | VersionParseException | ParseException | + base = was existing base class + New local exceptions:\ ConnectionCloseException, ConnectionIdleException, ParseException diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index ced4d0851b9..02bb24407e8 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -2359,12 +2359,12 @@ private int parseMessage(ref MessageInfo info) else { TraceUtil.traceRecv(info.stream, _logger, _traceLevels); - info.requestCount = info.stream.readInt(); - if (info.requestCount < 0) + int requestCount = info.stream.readInt(); + if (requestCount < 0) { - info.requestCount = 0; - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException($"Received batch request with {requestCount} batches."); } + info.requestCount = requestCount; info.adapter = _adapter; info.upcallCount += info.requestCount; diff --git a/csharp/src/Ice/IncomingRequest.cs b/csharp/src/Ice/IncomingRequest.cs index edc0c2ee62e..3f2555aa131 100644 --- a/csharp/src/Ice/IncomingRequest.cs +++ b/csharp/src/Ice/IncomingRequest.cs @@ -48,7 +48,7 @@ public IncomingRequest(int requestId, Connection? connection, ObjectAdapter adap { if (facetPath.Length > 1) { - throw new Ice.MarshalException(); + throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements."); } facet = facetPath[0]; } diff --git a/csharp/src/Ice/InputStream.cs b/csharp/src/Ice/InputStream.cs index 6d087e4f35d..b2b4ee69121 100644 --- a/csharp/src/Ice/InputStream.cs +++ b/csharp/src/Ice/InputStream.cs @@ -313,7 +313,7 @@ public void setLogger(Logger logger) /// /// If true (the default), slicing is enabled; if false, /// slicing is disabled. If slicing is disabled and the stream encounters a Slice type ID - /// during decoding for which no value factory is installed, it raises NoValueFactoryException. + /// during decoding for which no value factory is installed, it raises MarshalException. /// public void setSliceValues(bool b) { @@ -511,11 +511,11 @@ public EncodingVersion startEncapsulation() int sz = readInt(); if (sz < 6) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } if (sz - 4 > _buf.b.remaining()) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } _encapsStack.sz = sz; @@ -538,14 +538,14 @@ public void endEncapsulation() skipOptionals(); if (_buf.b.position() != _encapsStack.start + _encapsStack.sz) { - throw new EncapsulationException(); + throw new MarshalException("Failed to unmarshal encapsulation."); } } else if (_buf.b.position() != _encapsStack.start + _encapsStack.sz) { if (_buf.b.position() + 1 != _encapsStack.start + _encapsStack.sz) { - throw new EncapsulationException(); + throw new MarshalException("Failed to unmarshal encapsulation."); } // @@ -560,7 +560,7 @@ public void endEncapsulation() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -580,11 +580,11 @@ public EncodingVersion skipEmptyEncapsulation() int sz = readInt(); if (sz < 6) { - throw new EncapsulationException(); + throw new MarshalException($"{sz} is not a valid encapsulation size."); } if (sz - 4 > _buf.b.remaining()) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } var encoding = new EncodingVersion(this); @@ -594,7 +594,7 @@ public EncodingVersion skipEmptyEncapsulation() { if (sz != 6) { - throw new EncapsulationException(); + throw new MarshalException($"{sz} is not a valid encapsulation size for a 1.0 empty encapsulation."); } } else @@ -617,12 +617,12 @@ public byte[] readEncapsulation(out EncodingVersion encoding) int sz = readInt(); if (sz < 6) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } if (sz - 4 > _buf.b.remaining()) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } encoding = new EncodingVersion(this); @@ -636,7 +636,7 @@ public byte[] readEncapsulation(out EncodingVersion encoding) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -668,7 +668,7 @@ public EncodingVersion skipEncapsulation() int sz = readInt(); if (sz < 6) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } EncodingVersion encoding = new EncodingVersion(this); try @@ -677,7 +677,7 @@ public EncodingVersion skipEncapsulation() } catch (ArgumentOutOfRangeException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } return encoding; } @@ -751,7 +751,7 @@ public int readSize() int v = _buf.b.getInt(); if (v < 0) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } return v; } @@ -762,7 +762,7 @@ public int readSize() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -813,7 +813,7 @@ public int readAndCheckSeqSize(int minSize) // if (_startSeq + _minSeqSize > _buf.size()) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } return sz; @@ -831,7 +831,7 @@ public void readBlob(byte[] v) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -844,7 +844,7 @@ public byte[] readBlob(int sz) { if (_buf.b.remaining() < sz) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } byte[] v = new byte[sz]; try @@ -854,7 +854,7 @@ public byte[] readBlob(int sz) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -889,7 +889,7 @@ public byte readByte() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -943,7 +943,7 @@ public byte[] readByteSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1051,7 +1051,7 @@ public bool readBool() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1105,7 +1105,7 @@ public bool[] readBoolSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1213,7 +1213,7 @@ public short readShort() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1267,7 +1267,7 @@ public short[] readShortSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1377,7 +1377,7 @@ public int readInt() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1431,7 +1431,7 @@ public int[] readIntSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1466,7 +1466,7 @@ public void readIntSeq(out LinkedList l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1493,7 +1493,7 @@ public void readIntSeq(out Queue l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1561,7 +1561,7 @@ public long readLong() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1615,7 +1615,7 @@ public long[] readLongSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1650,7 +1650,7 @@ public void readLongSeq(out LinkedList l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1677,7 +1677,7 @@ public void readLongSeq(out Queue l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1745,7 +1745,7 @@ public float readFloat() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1799,7 +1799,7 @@ public float[] readFloatSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1834,7 +1834,7 @@ public void readFloatSeq(out LinkedList l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1861,7 +1861,7 @@ public void readFloatSeq(out Queue l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1929,7 +1929,7 @@ public double readDouble() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -1983,7 +1983,7 @@ public double[] readDoubleSeq() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -2018,7 +2018,7 @@ public void readDoubleSeq(out LinkedList l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -2045,7 +2045,7 @@ public void readDoubleSeq(out Queue l) } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } } @@ -2121,7 +2121,7 @@ public string readString() // if (_buf.b.remaining() < len) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } try @@ -2139,7 +2139,7 @@ public string readString() } catch (InvalidOperationException ex) { - throw new UnmarshalOutOfBoundsException(ex); + throw new MarshalException(endOfBufferMessage, ex); } catch (ArgumentException ex) { @@ -2452,7 +2452,7 @@ public void skip(int size) { if (size < 0 || size > _buf.b.remaining()) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } _buf.b.position(_buf.b.position() + size); } @@ -2633,9 +2633,9 @@ private bool skipOptionals() { return (UserException?)_instance!.getActivator().CreateInstance(id); } - catch (Exception ex) + catch (System.Exception ex) { - throw new MarshalException(ex); + throw new MarshalException($"Failed to create user exception with type ID '{id}'.", ex); } } @@ -2703,7 +2703,7 @@ protected string readTypeId(bool isIndex) int index = _stream.readSize(); if (!_typeIdMap.TryGetValue(index, out string? typeId)) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } return typeId; } @@ -2749,9 +2749,9 @@ protected string readTypeId(bool isIndex) { v = (Value?)_stream._instance!.getActivator().CreateInstance(typeId); } - catch (Exception ex) + catch (System.Exception ex) { - throw new NoValueFactoryException("no value factory", typeId, ex); + throw new MarshalException($"Failed to create a class with type ID '{typeId}'.", ex); } } @@ -3000,12 +3000,11 @@ internal override void throwException(UserExceptionFactory? factory) { startSlice(); } - catch (UnmarshalOutOfBoundsException) + catch (MarshalException) { // An oversight in the 1.0 encoding means there is no marker to indicate // the last slice of an exception. As a result, we just try to read the - // next type ID, which raises UnmarshalOutOfBoundsException when the - // input buffer underflows. + // next type ID, which raises MarshalException when the input buffer underflows. throw new MarshalException($"unknown exception type '{mostDerivedId}'"); } } @@ -3069,7 +3068,7 @@ internal override string startSlice() _sliceSize = _stream.readInt(); if (_sliceSize < 4) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } return _typeId; @@ -3149,7 +3148,7 @@ private void readInstance() // if (_typeId == Value.ice_staticId()) { - throw new NoValueFactoryException("", mostDerivedId); + throw new MarshalException($"Cannot find value factory for type ID '{mostDerivedId}'."); } v = newInstance(_typeId); @@ -3167,7 +3166,8 @@ private void readInstance() // if (!_sliceValues) { - throw new NoValueFactoryException("no value factory found and slicing is disabled", _typeId); + throw new MarshalException( + $"Cannot find value factory for type ID '{_typeId}' and slicing is disabled."); } // @@ -3406,7 +3406,7 @@ internal override string startSlice() _current.sliceSize = _stream.readInt(); if (_current.sliceSize < 4) { - throw new UnmarshalOutOfBoundsException(); + throw new MarshalException(endOfBufferMessage); } } else @@ -3500,9 +3500,8 @@ internal override void skipSlice() { if (_current.sliceType == SliceType.ValueSlice) { - throw new NoValueFactoryException("no value factory found and compact format prevents " + - "slicing (the sender should use the sliced format " + - "instead)", _current.typeId); + throw new MarshalException( + $"Cannot find value factory for type ID '{ _current.typeId}' and compact format prevents slicing."); } else { @@ -3640,7 +3639,8 @@ private int readInstance(int index, System.Action? cb) // if (!_sliceValues) { - throw new NoValueFactoryException("no value factory found and slicing is disabled", typeId); + throw new MarshalException( + $"Cannot find value factory for type ID '{typeId}' and slicing is disabled."); } // @@ -3859,6 +3859,8 @@ private void initEncaps() private ValueFactoryManager? _valueFactoryManager; private Logger? _logger; + + private const string endOfBufferMessage = "Attempting to unmarshal past the end of the buffer."; } /// diff --git a/csharp/src/Ice/Internal/Ex.cs b/csharp/src/Ice/Internal/Ex.cs index 5b49ca2ba8f..b1000773044 100644 --- a/csharp/src/Ice/Internal/Ex.cs +++ b/csharp/src/Ice/Internal/Ex.cs @@ -8,15 +8,10 @@ public static class Ex { public static void throwUOE(Type expectedType, Ice.Value v) { - // - // If the object is an unknown sliced object, we didn't find an - // value factory, in this case raise a NoValueFactoryException - // instead. - // - if (v is Ice.UnknownSlicedValue) + // If the object is an unknown sliced object, we didn't find an value factory. + if (v is UnknownSlicedValue usv) { - Ice.UnknownSlicedValue usv = (Ice.UnknownSlicedValue)v; - throw new Ice.NoValueFactoryException("", usv.ice_id()); + throw new MarshalException($"Cannot find value factory to unmarshal class with type ID `{usv.ice_id()}'."); } string type = v.ice_id(); @@ -31,14 +26,14 @@ public static void throwUOE(Type expectedType, Ice.Value v) Debug.Assert(false); } - throw new Ice.UnexpectedObjectException("expected element of type `" + expected + "' but received `" + - type + "'", type, expected); + throw new MarshalException( + $"Failed to unmarshal class with type ID '{expected}': value factory returned class with type ID '{type}'."); } public static void throwMemoryLimitException(int requested, int maximum) { - throw new Ice.MemoryLimitException("requested " + requested + " bytes, maximum allowed is " + maximum + - " bytes (see Ice.MessageSizeMax)"); + throw new MarshalException( + $"Cannot unmarshal Ice message: the message size of {requested} bytes exceeds the maximum allowed of {maximum} bytes (see Ice.MessageSizeMax)."); } } diff --git a/csharp/src/Ice/Internal/OutgoingAsync.cs b/csharp/src/Ice/Internal/OutgoingAsync.cs index d3bef0979fd..a96721e7d82 100644 --- a/csharp/src/Ice/Internal/OutgoingAsync.cs +++ b/csharp/src/Ice/Internal/OutgoingAsync.cs @@ -762,7 +762,7 @@ public override bool response() { if (facetPath.Length > 1) { - throw new Ice.MarshalException(); + throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements."); } facet = facetPath[0]; } diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index da359ad5670..a1a14d6bf27 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -517,7 +517,7 @@ public Reference create(Ice.Identity ident, Ice.InputStream s) { if (facetPath.Length > 1) { - throw new Ice.ProxyUnmarshalException(); + throw new MarshalException($"Received invalid proxy facet path with {facetPath.Length} elements."); } facet = facetPath[0]; } @@ -529,7 +529,7 @@ public Reference create(Ice.Identity ident, Ice.InputStream s) int mode = s.readByte(); if (mode < 0 || mode > (int)Reference.Mode.ModeLast) { - throw new Ice.ProxyUnmarshalException(); + throw new MarshalException($"Received invalid proxy mode {mode}"); } bool secure = s.readBool(); diff --git a/csharp/src/Ice/Internal/RequestHandlerCache.cs b/csharp/src/Ice/Internal/RequestHandlerCache.cs index 6599f06f94d..fb54673d752 100644 --- a/csharp/src/Ice/Internal/RequestHandlerCache.cs +++ b/csharp/src/Ice/Internal/RequestHandlerCache.cs @@ -215,9 +215,8 @@ private static int checkRetryAfterException(Ice.LocalException ex, Reference @re // instead), which means there was a problem in this process that will // not change if we try again. // - // The most likely cause for a MarshalException is exceeding the - // maximum message size, which is represented by the subclass - // MemoryLimitException. For example, a client can attempt to send a + // A likely cause for a MarshalException is exceeding the + // maximum message size. For example, a client can attempt to send a // message that exceeds the maximum memory size, or accumulate enough // batch requests without flushing that the maximum size is reached. // diff --git a/csharp/src/Ice/Internal/WSTransceiver.cs b/csharp/src/Ice/Internal/WSTransceiver.cs index 74b99d0ba95..d9b42ec2c2d 100644 --- a/csharp/src/Ice/Internal/WSTransceiver.cs +++ b/csharp/src/Ice/Internal/WSTransceiver.cs @@ -127,7 +127,9 @@ public int initialize(Buffer readBuffer, Buffer writeBuffer, ref bool hasMoreDat int oldSize = _readBuffer.b.position(); if (oldSize + 1024 > _instance.messageSizeMax()) { - throw new Ice.MemoryLimitException(); + Ex.throwMemoryLimitException( + requested: oldSize + 1024, + maximum: _instance.messageSizeMax()); } _readBuffer.resize(oldSize + 1024, true); _readBuffer.b.position(oldSize); @@ -273,11 +275,6 @@ public int closing(bool initiator, Ice.LocalException reason) { _closingReason = CLOSURE_PROTOCOL_ERROR; } - else if (reason is Ice.MemoryLimitException) - { - _closingReason = CLOSURE_TOO_BIG; - } - if (_state == StateOpened) { _state = StateClosingRequestPending; @@ -1684,7 +1681,6 @@ private void prepareWriteHeader(byte opCode, int payloadLength) private const int CLOSURE_NORMAL = 1000; private const int CLOSURE_SHUTDOWN = 1001; private const int CLOSURE_PROTOCOL_ERROR = 1002; - private const int CLOSURE_TOO_BIG = 1009; private const string _iceProtocol = "ice.zeroc.com"; private const string _wsUUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 55efd853868..a8378641e91 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -155,6 +155,19 @@ public ConnectionIdleException(string message) public override string ice_id() => "::Ice::ConnectionIdleException"; } +/// +/// This exception reports an error during marshaling or unmarshaling. +/// +public sealed class MarshalException : ProtocolException +{ + public MarshalException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::MarshalException"; +} + /// /// Reports a failure that occurred while parsing a string. /// diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 26689369a6c..2643bd39431 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -1100,235 +1100,6 @@ public override string ice_id() } } -/// -/// This exception is raised for errors during marshaling or unmarshaling data. -/// -public class MarshalException : ProtocolException -{ - public MarshalException() - { - } - - public MarshalException(System.Exception ex) : base(ex) - { - } - - public MarshalException(string reason) : base(reason) - { - } - - public MarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MarshalException"; - } -} - -/// -/// This exception is raised if inconsistent data is received while unmarshaling a proxy. -/// -public class ProxyUnmarshalException : MarshalException -{ - public ProxyUnmarshalException() - { - } - - public ProxyUnmarshalException(System.Exception ex) : base(ex) - { - } - - public ProxyUnmarshalException(string reason) : base(reason) - { - } - - public ProxyUnmarshalException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ProxyUnmarshalException"; - } -} - -/// -/// This exception is raised if an out-of-bounds condition occurs during unmarshaling. -/// -public class UnmarshalOutOfBoundsException : MarshalException -{ - public UnmarshalOutOfBoundsException() - { - } - - public UnmarshalOutOfBoundsException(System.Exception ex) : base(ex) - { - } - - public UnmarshalOutOfBoundsException(string reason) : base(reason) - { - } - - public UnmarshalOutOfBoundsException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnmarshalOutOfBoundsException"; - } -} - -/// -/// This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. -/// -public class NoValueFactoryException : MarshalException -{ - public string type; - - private void _initDM() - { - this.type = ""; - } - - public NoValueFactoryException() - { - _initDM(); - } - - public NoValueFactoryException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type) - { - this.type = type; - } - - public NoValueFactoryException(string reason, string type) : base(reason) - { - _initDM(type); - } - - public NoValueFactoryException(string reason, string type, System.Exception ex) : base(reason, ex) - { - _initDM(type); - } - - public override string ice_id() - { - return "::Ice::NoValueFactoryException"; - } -} - -/// -/// This exception is raised if the type of an unmarshaled Slice class instance does not match its expected type. -/// This -/// can happen if client and server are compiled with mismatched Slice definitions or if a class of the wrong type is -/// passed as a parameter or return value using dynamic invocation. This exception can also be raised if IceStorm is -/// used to send Slice class instances and an operation is subscribed to the wrong topic. -/// -public class UnexpectedObjectException : MarshalException -{ - public string type; - public string expectedType; - - private void _initDM() - { - this.type = ""; - this.expectedType = ""; - } - - public UnexpectedObjectException() - { - _initDM(); - } - - public UnexpectedObjectException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string type, string expectedType) - { - this.type = type; - this.expectedType = expectedType; - } - - public UnexpectedObjectException(string reason, string type, string expectedType) : base(reason) - { - _initDM(type, expectedType); - } - - public UnexpectedObjectException(string reason, string type, string expectedType, System.Exception ex) : base(reason, ex) - { - _initDM(type, expectedType); - } - - public override string ice_id() - { - return "::Ice::UnexpectedObjectException"; - } -} - -/// -/// This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the -/// Ice.MessageSizeMax property. -/// -public class MemoryLimitException : MarshalException -{ - public MemoryLimitException() - { - } - - public MemoryLimitException(System.Exception ex) : base(ex) - { - } - - public MemoryLimitException(string reason) : base(reason) - { - } - - public MemoryLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::MemoryLimitException"; - } -} - -/// -/// This exception indicates a malformed data encapsulation. -/// -public class EncapsulationException : MarshalException -{ - public EncapsulationException() - { - } - - public EncapsulationException(System.Exception ex) : base(ex) - { - } - - public EncapsulationException(string reason) : base(reason) - { - } - - public EncapsulationException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::EncapsulationException"; - } -} - /// /// This exception is raised if an unsupported feature is used. /// The unsupported feature string contains the name of the diff --git a/csharp/src/Ice/OutputStream.cs b/csharp/src/Ice/OutputStream.cs index 54bc1a98107..69470ef289f 100644 --- a/csharp/src/Ice/OutputStream.cs +++ b/csharp/src/Ice/OutputStream.cs @@ -376,7 +376,7 @@ public void writeEncapsulation(byte[] v) { if (v.Length < 6) { - throw new EncapsulationException(); + throw new MarshalException($"A byte sequence with {v.Length} bytes is not a valid encapsulation."); } expand(v.Length); _buf.b.put(v); diff --git a/csharp/src/Ice/ValueFactory.cs b/csharp/src/Ice/ValueFactory.cs index 2246b4eec8e..1de40a97670 100644 --- a/csharp/src/Ice/ValueFactory.cs +++ b/csharp/src/Ice/ValueFactory.cs @@ -18,8 +18,8 @@ public interface ValueFactoryManager /// value was marshaled: /// If the value uses the "sliced" format, Ice ascends the class hierarchy until it finds a type that is recognized /// by a factory, or it reaches the least-derived type. If no factory is found that can create an instance, the run - /// time throws NoValueFactoryException. - /// If the value uses the "compact" format, Ice immediately raises NoValueFactoryException. + /// time throws a MarshalException. + /// If the value uses the "compact" format, Ice immediately raises a MarshalException. /// The following order is used to locate a factory for a type: /// /// The Ice run-time looks for a factory registered specifically for the type. diff --git a/csharp/test/Ice/exceptions/AllTests.cs b/csharp/test/Ice/exceptions/AllTests.cs index 7106d34cd54..dbbb271bc93 100644 --- a/csharp/test/Ice/exceptions/AllTests.cs +++ b/csharp/test/Ice/exceptions/AllTests.cs @@ -403,8 +403,9 @@ public virtual void called() thrower.throwMemoryLimitException(null); test(false); } - catch (MemoryLimitException) + catch (MarshalException ex) { + test(ex.Message.Contains("exceeds the maximum allowed")); } catch (Exception) { @@ -436,9 +437,11 @@ public virtual void called() { thrower2.throwMemoryLimitException(new byte[2 * 1024 * 1024]); // 2MB(no limits) } - catch (MemoryLimitException) + catch (MarshalException ex) { + test(ex.Message.Contains("exceeds the maximum allowed")); } + var thrower3 = Test.ThrowerPrxHelper.uncheckedCast( communicator.stringToProxy("thrower:" + helper.getTestEndpoint(2))); try diff --git a/csharp/test/Ice/objects/AllTests.cs b/csharp/test/Ice/objects/AllTests.cs index 7af10b87b0a..93d300f2eb5 100644 --- a/csharp/test/Ice/objects/AllTests.cs +++ b/csharp/test/Ice/objects/AllTests.cs @@ -379,10 +379,10 @@ public static Test.InitialPrx allTests(global::Test.TestHelper helper) uoet.op(); test(false); } - catch (Ice.UnexpectedObjectException ex) + catch (Ice.MarshalException ex) { - test(ex.type == "::Test::AlsoEmpty"); - test(ex.expectedType == "::Test::Empty"); + test(ex.Message.Contains("'::Test::AlsoEmpty'")); + test(ex.Message.Contains("'::Test::Empty'")); } catch (System.Exception ex) { diff --git a/csharp/test/Ice/operations/BatchOneways.cs b/csharp/test/Ice/operations/BatchOneways.cs index a1d2a346f36..8083821ce98 100644 --- a/csharp/test/Ice/operations/BatchOneways.cs +++ b/csharp/test/Ice/operations/BatchOneways.cs @@ -73,7 +73,7 @@ internal static void batchOneways(global::Test.TestHelper helper, Test.MyClassPr { batch.opByteSOneway(bs1); } - catch (Ice.MemoryLimitException) + catch (Ice.MarshalException) { test(false); } diff --git a/csharp/test/Ice/slicing/objects/AllTests.cs b/csharp/test/Ice/slicing/objects/AllTests.cs index b774fc823d8..dec1ecd37b0 100644 --- a/csharp/test/Ice/slicing/objects/AllTests.cs +++ b/csharp/test/Ice/slicing/objects/AllTests.cs @@ -239,7 +239,7 @@ public static TestIntfPrx allTests(Test.TestHelper helper, bool collocated) testPrx.SBSUnknownDerivedAsSBaseCompact(); test(false); } - catch (Ice.NoValueFactoryException) + catch (Ice.MarshalException) { // Expected. } @@ -279,7 +279,7 @@ public static TestIntfPrx allTests(Test.TestHelper helper, bool collocated) } catch (AggregateException ae) { - test(ae.InnerException is Ice.NoValueFactoryException); + test(ae.InnerException is Ice.MarshalException); } } output.WriteLine("ok"); @@ -296,7 +296,7 @@ public static TestIntfPrx allTests(Test.TestHelper helper, bool collocated) test((o as Ice.UnknownSlicedValue).ice_getSlicedData() != null); testPrx.checkSUnknown(o); } - catch (Ice.NoValueFactoryException) + catch (Ice.MarshalException) { test(testPrx.ice_getEncodingVersion().Equals(Ice.Util.Encoding_1_0)); } @@ -321,14 +321,7 @@ public static TestIntfPrx allTests(Test.TestHelper helper, bool collocated) } catch (AggregateException ae) { - try - { - throw ae.InnerException; - } - catch (Ice.Exception ex) - { - test(ex.GetType().FullName == "Ice.NoValueFactoryException"); - } + test(ae.InnerException is Ice.MarshalException); } } else diff --git a/csharp/test/Ice/stream/AllTests.cs b/csharp/test/Ice/stream/AllTests.cs index 2b708b28dc7..eddc499d301 100644 --- a/csharp/test/Ice/stream/AllTests.cs +++ b/csharp/test/Ice/stream/AllTests.cs @@ -175,7 +175,7 @@ static public int allTests(global::Test.TestHelper helper) inS.readBool(); test(false); } - catch (Ice.UnmarshalOutOfBoundsException) + catch (Ice.MarshalException) { } } From a32b121abf1f1242de3e5b16b95f8066513d5097 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 12:31:09 -0400 Subject: [PATCH 09/21] Move more exceptions --- CHANGELOG-3.8.md | 10 +- csharp/src/Ice/ConnectionI.cs | 55 ++- csharp/src/Ice/Internal/BZip2.cs | 6 +- csharp/src/Ice/Internal/OutgoingAsync.cs | 14 +- csharp/src/Ice/Internal/Protocol.cs | 55 +-- csharp/src/Ice/Internal/ReferenceFactory.cs | 2 +- csharp/src/Ice/LocalExceptions.cs | 131 ++++- csharp/src/Ice/LoggerPlugin.cs | 8 +- csharp/src/Ice/ObjectAdapter.cs | 12 +- csharp/src/Ice/OldLocalExceptions.cs | 500 -------------------- csharp/src/Ice/PluginManagerI.cs | 63 +-- csharp/src/Ice/ThreadHookPlugin.cs | 4 +- csharp/test/Ice/proxy/AllTests.cs | 16 +- 13 files changed, 216 insertions(+), 660 deletions(-) diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index f46b449aac1..888fc2ee6b2 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -61,10 +61,14 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG - Consolidate and refactor the exceptions derived from LocalException. | Local exception in Ice 3.7 | Replacement | |-------------------------------------|----------------------------| + | BadMagicException | ProtocolException (base) | + | CompressionException | ProtocolException (base) | + | ConnectionNotValidatedException | ProtocolException (base) | | EncapsulationException | MarshalException (base) | | EndpointParseException | ParseException | | EndpointSelectionTypeParseException | ParseException | | IllegalIdentityException | ArgumentException (C#) | + | IllegalMessageSizeException | MarshalException | | IllegalServantException | ArgumentNullException (C#) | | IdentityParseException | ParseException | | MemoryLimitException | MarshalException (base) | @@ -72,13 +76,17 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG | ProxyParseException | ParseException | | ProxyUnmarshalException | MarshalException (base) | | UnexpectedObjectException | MarshalException (base) | + | UnknownMessageException | ProtocolException (base) | + | UnknownReplyStatusException | MarshalException | | UnmarshalOutOfBoundsException | MarshalException (base) | + | UnsupportedEncodingException | MarshalException | + | UnsupportedProtocolException | MarshalException, FeatureNotSupportedException | | VersionParseException | ParseException | base = was existing base class New local exceptions:\ - ConnectionCloseException, ConnectionIdleException, ParseException + ConnectionClosedException, ConnectionIdleException, ParseException ## Slice Language Changes diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 02bb24407e8..af107df30ee 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -884,7 +884,7 @@ public override void message(ref ThreadPoolCurrent current) // // This situation is possible for small UDP packets. // - throw new IllegalMessageSizeException(); + throw new MarshalException("Received Ice message with too few bytes in header."); } // Decode the header. @@ -897,22 +897,29 @@ public override void message(ref ThreadPoolCurrent current) if (m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) { - BadMagicException ex = new BadMagicException(); - ex.badMagic = m; - throw ex; + throw new ProtocolException( + $"Bad magic in message header: {m[0]:X2} {m[1]:X2} {m[2]:X2} {m[3]:X2}"); } - ProtocolVersion pv = new ProtocolVersion(_readStream); - Protocol.checkSupportedProtocol(pv); - EncodingVersion ev = new EncodingVersion(_readStream); - Protocol.checkSupportedProtocolEncoding(ev); + var pv = new ProtocolVersion(_readStream); + if (pv != Util.currentProtocol) + { + throw new MarshalException( + $"Invalid protocol version in message header: {pv.major}.{pv.minor}"); + } + var ev = new EncodingVersion(_readStream); + if (ev != Util.currentProtocolEncoding) + { + throw new MarshalException( + $"Invalid protocol encoding version in message header: {ev.major}.{ev.minor}"); + } _readStream.readByte(); // messageType _readStream.readByte(); // compress int size = _readStream.readInt(); if (size < Protocol.headerSize) { - throw new IllegalMessageSizeException(); + throw new MarshalException($"Received Ice message with unexpected size {size}."); } // Resize the read buffer to the message size. @@ -1921,27 +1928,34 @@ private bool validate(int operation) if (m[0] != Protocol.magic[0] || m[1] != Protocol.magic[1] || m[2] != Protocol.magic[2] || m[3] != Protocol.magic[3]) { - BadMagicException ex = new BadMagicException(); - ex.badMagic = m; - throw ex; + throw new ProtocolException( + $"Bad magic in message header: {m[0]:X2} {m[1]:X2} {m[2]:X2} {m[3]:X2}"); } - ProtocolVersion pv = new ProtocolVersion(_readStream); - Protocol.checkSupportedProtocol(pv); - - EncodingVersion ev = new EncodingVersion(_readStream); - Protocol.checkSupportedProtocolEncoding(ev); + var pv = new ProtocolVersion(_readStream); + if (pv != Util.currentProtocol) + { + throw new MarshalException( + $"Invalid protocol version in message header: {pv.major}.{pv.minor}"); + } + var ev = new EncodingVersion(_readStream); + if (ev != Util.currentProtocolEncoding) + { + throw new MarshalException( + $"Invalid protocol encoding version in message header: {ev.major}.{ev.minor}"); + } byte messageType = _readStream.readByte(); if (messageType != Protocol.validateConnectionMsg) { - throw new ConnectionNotValidatedException(); + throw new ProtocolException( + $"Received message of type {messageType} on connection that is not yet validated."); } _readStream.readByte(); // Ignore compression status for validate connection. int size = _readStream.readInt(); if (size != Protocol.headerSize) { - throw new IllegalMessageSizeException(); + throw new MarshalException($"Received ValidateConnection message with unexpected size {size}."); } TraceUtil.traceRecv(_readStream, _logger, _traceLevels); } @@ -2422,7 +2436,8 @@ private int parseMessage(ref MessageInfo info) { TraceUtil.trace("received unknown message\n(invalid, closing connection)", info.stream, _logger, _traceLevels); - throw new UnknownMessageException(); + + throw new ProtocolException($"Received Ice protocol message with unknown type: {messageType}"); } } } diff --git a/csharp/src/Ice/Internal/BZip2.cs b/csharp/src/Ice/Internal/BZip2.cs index 1a9d9d37bb7..783d70ed8db 100644 --- a/csharp/src/Ice/Internal/BZip2.cs +++ b/csharp/src/Ice/Internal/BZip2.cs @@ -316,7 +316,7 @@ public static Buffer compress(Buffer buf, int headerSize, int compressionLevel) } else if (rc < 0) { - throw new CompressionException($"BZ2_bzBuffToBuffCompress failed: {getBZ2Error(rc)}"); + throw new ProtocolException($"BZ2_bzBuffToBuffCompress failed: {getBZ2Error(rc)}"); } // @@ -360,7 +360,7 @@ public static Buffer uncompress(Buffer buf, int headerSize, int messageSizeMax) int uncompressedSize = buf.b.getInt(); if (uncompressedSize <= headerSize) { - throw new Ice.IllegalMessageSizeException("compressed size <= header size"); + throw new MarshalException($"Unexpected message size after uncompress: {uncompressedSize}"); } if (uncompressedSize > messageSizeMax) { @@ -375,7 +375,7 @@ public static Buffer uncompress(Buffer buf, int headerSize, int messageSizeMax) int rc = _decompressBuffer(uncompressed, ref uncompressedLen, compressed, compressedLen, 0, 0); if (rc < 0) { - throw new CompressionException($"BZ2_bzBuffToBuffDecompress failed: {getBZ2Error(rc)}"); + throw new ProtocolException($"BZ2_bzBuffToBuffDecompress failed: {getBZ2Error(rc)}"); } Buffer r = new Buffer(); diff --git a/csharp/src/Ice/Internal/OutgoingAsync.cs b/csharp/src/Ice/Internal/OutgoingAsync.cs index a96721e7d82..f2b62b8b967 100644 --- a/csharp/src/Ice/Internal/OutgoingAsync.cs +++ b/csharp/src/Ice/Internal/OutgoingAsync.cs @@ -643,7 +643,11 @@ public OutgoingAsync(Ice.ObjectPrxHelperBase prx, OutgoingAsyncCompletionCallbac public void prepare(string operation, Ice.OperationMode mode, Dictionary context) { - Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(proxy_.iceReference().getProtocol())); + if (proxy_.iceReference().getProtocol().major != Ice.Util.currentProtocol.major) + { + throw new FeatureNotSupportedException( + $"Cannot send request using protocol version {proxy_.iceReference().getProtocol()}."); + } mode_ = mode; @@ -845,7 +849,7 @@ public override bool response() default: { - throw new Ice.UnknownReplyStatusException(); + throw new MarshalException($"Received reply message with unknown reply status {replyStatus}."); } } @@ -1093,7 +1097,11 @@ public override int invokeCollocated(CollocatedRequestHandler handler) public void invoke(string operation, bool synchronous) { - Protocol.checkSupportedProtocol(Protocol.getCompatibleProtocol(proxy_.iceReference().getProtocol())); + if (proxy_.iceReference().getProtocol().major != Ice.Util.currentProtocol.major) + { + throw new FeatureNotSupportedException( + $"Cannot send request using protocol version {proxy_.iceReference().getProtocol()}."); + } synchronous_ = synchronous; observer_ = ObserverHelper.get(proxy_, operation, null); // Not used for proxy flush batch requests. diff --git a/csharp/src/Ice/Internal/Protocol.cs b/csharp/src/Ice/Internal/Protocol.cs index bd44550d38c..7a62596e4c0 100644 --- a/csharp/src/Ice/Internal/Protocol.cs +++ b/csharp/src/Ice/Internal/Protocol.cs @@ -85,55 +85,12 @@ public sealed class Protocol 0, 0, 0, 0 // Message size (placeholder). }; - internal static void - checkSupportedProtocol(Ice.ProtocolVersion v) - { - if (v.major != protocolMajor || v.minor > protocolMinor) - { - throw new Ice.UnsupportedProtocolException("", v, Ice.Util.currentProtocol); - } - } - - public static void - checkSupportedProtocolEncoding(Ice.EncodingVersion v) - { - if (v.major != protocolEncodingMajor || v.minor > protocolEncodingMinor) - { - throw new Ice.UnsupportedEncodingException("", v, Ice.Util.currentProtocolEncoding); - } - } - - internal static void - checkSupportedEncoding(Ice.EncodingVersion v) + internal static void checkSupportedEncoding(Ice.EncodingVersion v) { if (v.major != encodingMajor || v.minor > encodingMinor) { - throw new Ice.UnsupportedEncodingException("", v, Ice.Util.currentEncoding); - } - } - - // - // Either return the given protocol if not compatible, or the greatest - // supported protocol otherwise. - // - internal static Ice.ProtocolVersion - getCompatibleProtocol(Ice.ProtocolVersion v) - { - if (v.major != Ice.Util.currentProtocol.major) - { - return v; // Unsupported protocol, return as is. - } - else if (v.minor < Ice.Util.currentProtocol.minor) - { - return v; // Supported protocol. - } - else - { - // - // Unsupported but compatible, use the currently supported - // protocol, that's the best we can do. - // - return Ice.Util.currentProtocol; + throw new MarshalException( + $"This Ice runtime does not support encoding version {v.major}.{v.minor}"); } } @@ -162,12 +119,6 @@ internal static Ice.EncodingVersion } } - internal static bool - isSupported(Ice.ProtocolVersion version, Ice.ProtocolVersion supported) - { - return version.major == supported.major && version.minor <= supported.minor; - } - internal static bool isSupported(Ice.EncodingVersion version, Ice.EncodingVersion supported) { diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index a1a14d6bf27..14d41ae65ae 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -517,7 +517,7 @@ public Reference create(Ice.Identity ident, Ice.InputStream s) { if (facetPath.Length > 1) { - throw new MarshalException($"Received invalid proxy facet path with {facetPath.Length} elements."); + throw new MarshalException($"Received invalid facet path with {facetPath.Length} elements."); } facet = facetPath[0]; } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index a8378641e91..36424736f0d 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -132,7 +132,7 @@ public UnknownUserException(string message) /// /// This exception indicates that a connection was closed gracefully. /// -public class ConnectionClosedException : LocalException +public sealed class ConnectionClosedException : LocalException { public ConnectionClosedException(string message) : base(message, innerException: null) @@ -145,7 +145,7 @@ public ConnectionClosedException(string message) /// /// This exception indicates that a connection was aborted by the idle check. /// -public class ConnectionIdleException : LocalException +public sealed class ConnectionIdleException : LocalException { public ConnectionIdleException(string message) : base(message, innerException: null) @@ -156,16 +156,16 @@ public ConnectionIdleException(string message) } /// -/// This exception reports an error during marshaling or unmarshaling. +/// This exception is raised when a failure occurs during initialization. /// -public sealed class MarshalException : ProtocolException +public sealed class InitializationException : LocalException { - public MarshalException(string message, System.Exception? innerException = null) + public InitializationException(string message, System.Exception? innerException = null) : base(message, innerException) { } - public override string ice_id() => "::Ice::MarshalException"; + public override string ice_id() => "::Ice::InitializationException"; } /// @@ -182,3 +182,122 @@ public ParseException(string message, System.Exception? innerException = null) public override string ice_id() => "::Ice::ParseException"; } + +/// +/// This exception indicates that a failure occurred while initializing a plug-in. +/// +public sealed class PluginInitializationException : LocalException +{ + public PluginInitializationException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::PluginInitializationException"; +} + +/// +/// The base class for Ice protocol exceptions. +/// +public class ProtocolException : LocalException +{ + public ProtocolException(string? message = null, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::ProtocolException"; +} + +/// +/// This exception indicates that the connection has been gracefully closed by the server. +/// The operation call that caused this exception has not been executed by the server. In most cases you will not get +/// this exception because the client will automatically retry the operation call in case the server shut down the +/// connection. However, if upon retry the server shuts down the connection again, and the retry limit has been reached, +/// then this exception is propagated to the application code. +/// +public sealed class CloseConnectionException : ProtocolException +{ + public CloseConnectionException() + : base(message: "Connection closed by the peer.", innerException: null) + { + } + + public override string ice_id() => "::Ice::CloseConnectionException"; +} + +/// +/// A datagram exceeds the configured size. +/// This exception is raised if a datagram exceeds the configured send or receive buffer size, or exceeds the maximum +/// payload size of a UDP packet (65507 bytes). +/// +public sealed class DatagramLimitException : ProtocolException +{ + public DatagramLimitException() + : base(message: "Datagram limit exceeded.", innerException: null) + { + } + + public override string ice_id() => "::Ice::DatagramLimitException"; +} + +/// +/// This exception reports an error during marshaling or unmarshaling. +/// +public sealed class MarshalException : ProtocolException +{ + public MarshalException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::MarshalException"; +} + +/// This exception indicates a timeout condition. +public class TimeoutException : LocalException +{ + public TimeoutException(string? message = null, System.Exception? innerException = null) + : base(message ?? "Operation timed out.", innerException) + { + } + + public override string ice_id() => "::Ice::TimeoutException"; +} + +/// +/// This exception indicates a connection establishment timeout condition. +/// +public sealed class ConnectTimeoutException : TimeoutException +{ + public ConnectTimeoutException() + : base("Connect timed out.") + { + } + + public override string ice_id() => "::Ice::ConnectTimeoutException"; +} + +/// This exception indicates a connection closure timeout condition. +public sealed class CloseTimeoutException : TimeoutException +{ + public CloseTimeoutException() + : base("Close timed out.") + { + } + + public override string ice_id() => "::Ice::CloseTimeoutException"; +} + +/// +/// This exception indicates that an invocation failed because it timed out. +/// +public sealed class InvocationTimeoutException : TimeoutException +{ + public InvocationTimeoutException() + : base("Invocation timed out.") + { + } + + public override string ice_id() => "::Ice::InvocationTimeoutException"; +} diff --git a/csharp/src/Ice/LoggerPlugin.cs b/csharp/src/Ice/LoggerPlugin.cs index dc0fe6d9749..da62aa16d09 100644 --- a/csharp/src/Ice/LoggerPlugin.cs +++ b/csharp/src/Ice/LoggerPlugin.cs @@ -19,16 +19,12 @@ public class LoggerPlugin : Plugin { if (communicator == null) { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = "Communicator cannot be null"; - throw ex; + throw new PluginInitializationException("Communicator cannot be null."); } if (logger == null) { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = "Logger cannot be null"; - throw ex; + throw new PluginInitializationException("Logger cannot be null."); } Ice.Internal.Instance instance = communicator.instance; diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index 6dc00c15d1a..e7988035ba0 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1198,9 +1198,7 @@ internal ObjectAdapter( _state = StateDestroyed; _incomingConnectionFactories = []; - InitializationException ex = new InitializationException(); - ex.reason = "object adapter `" + _name + "' requires configuration"; - throw ex; + throw new InitializationException($"Object adapter '{name}' requires configuration."); } _id = properties.getProperty(_name + ".AdapterId"); @@ -1215,11 +1213,11 @@ internal ObjectAdapter( { _reference = _instance.referenceFactory().create("dummy " + proxyOptions, ""); } - catch (ParseException) + catch (ParseException ex) { - InitializationException ex = new InitializationException(); - ex.reason = "invalid proxy options `" + proxyOptions + "' for object adapter `" + _name + "'"; - throw ex; + throw new InitializationException( + $"Invalid proxy options '{proxyOptions}' for object adapter '{_name}'.", + ex); } { diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 2643bd39431..60f51827c22 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -2,92 +2,6 @@ namespace Ice; -/// -/// This exception is raised when a failure occurs during initialization. -/// -public class InitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public InitializationException() - { - _initDM(); - } - - public InitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public InitializationException(string reason) - { - _initDM(reason); - } - - public InitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::InitializationException"; - } -} - -/// -/// This exception indicates that a failure occurred while initializing a plug-in. -/// -public class PluginInitializationException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public PluginInitializationException() - { - _initDM(); - } - - public PluginInitializationException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public PluginInitializationException(string reason) - { - _initDM(reason); - } - - public PluginInitializationException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::PluginInitializationException"; - } -} - /// /// An attempt was made to register something more than once with the Ice run time. /// This exception is raised if an @@ -624,78 +538,6 @@ public override string ice_id() } } -/// This exception indicates a timeout condition. -public class TimeoutException : LocalException -{ - public TimeoutException() - { - } - - public TimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::TimeoutException"; - } -} - -/// -/// This exception indicates a connection establishment timeout condition. -/// -public class ConnectTimeoutException : TimeoutException -{ - public ConnectTimeoutException() - { - } - - public ConnectTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectTimeoutException"; - } -} - -/// This exception indicates a connection closure timeout condition. -public class CloseTimeoutException : TimeoutException -{ - public CloseTimeoutException() - { - } - - public CloseTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseTimeoutException"; - } -} - -/// -/// This exception indicates that an invocation failed because it timed out. -/// -public class InvocationTimeoutException : TimeoutException -{ - public InvocationTimeoutException() - { - } - - public InvocationTimeoutException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationTimeoutException"; - } -} - /// /// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. /// @@ -715,266 +557,6 @@ public override string ice_id() } } -/// -/// A generic exception base for all kinds of protocol error conditions. -/// -public class ProtocolException : LocalException -{ - public string reason => Message; - - public ProtocolException(string message = null, System.Exception innerException = null) - : base(message, innerException) - { - } - - public ProtocolException(System.Exception innerException) - : this(message: null, innerException) - { - } - - public override string ice_id() => "::Ice::ProtocolException"; -} - -/// -/// This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). -/// -public class BadMagicException : ProtocolException -{ - public byte[] badMagic; - - public BadMagicException() - { - } - - public BadMagicException(System.Exception ex) : base(ex) - { - } - - private void _initDM(byte[] badMagic) - { - this.badMagic = badMagic; - } - - public BadMagicException(string reason, byte[] badMagic) : base(reason) - { - _initDM(badMagic); - } - - public BadMagicException(string reason, byte[] badMagic, System.Exception ex) : base(reason, ex) - { - _initDM(badMagic); - } - - public override string ice_id() - { - return "::Ice::BadMagicException"; - } -} - -/// -/// This exception indicates an unsupported protocol version. -/// -public class UnsupportedProtocolException : ProtocolException -{ - public ProtocolVersion bad; - public ProtocolVersion supported; - - private void _initDM() - { - this.bad = new ProtocolVersion(); - this.supported = new ProtocolVersion(); - } - - public UnsupportedProtocolException() - { - _initDM(); - } - - public UnsupportedProtocolException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(ProtocolVersion bad, ProtocolVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedProtocolException(string reason, ProtocolVersion bad, ProtocolVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - - public override string ice_id() - { - return "::Ice::UnsupportedProtocolException"; - } -} - -/// -/// This exception indicates an unsupported data encoding version. -/// -public class UnsupportedEncodingException : ProtocolException -{ - public EncodingVersion bad; - public EncodingVersion supported; - - private void _initDM() - { - this.bad = new EncodingVersion(); - this.supported = new EncodingVersion(); - } - - public UnsupportedEncodingException() - { - _initDM(); - } - - public UnsupportedEncodingException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(EncodingVersion bad, EncodingVersion supported) - { - this.bad = bad; - this.supported = supported; - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported) : base(reason) - { - _initDM(bad, supported); - } - - public UnsupportedEncodingException(string reason, EncodingVersion bad, EncodingVersion supported, System.Exception ex) : base(reason, ex) - { - _initDM(bad, supported); - } - public override string ice_id() - { - return "::Ice::UnsupportedEncodingException"; - } -} - -/// -/// This exception indicates that an unknown protocol message has been received. -/// -public class UnknownMessageException : ProtocolException -{ - public UnknownMessageException() - { - } - - public UnknownMessageException(System.Exception ex) : base(ex) - { - } - - public UnknownMessageException(string reason) : base(reason) - { - } - - public UnknownMessageException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownMessageException"; - } -} - -/// -/// This exception is raised if a message is received over a connection that is not yet validated. -/// -public class ConnectionNotValidatedException : ProtocolException -{ - public ConnectionNotValidatedException() - { - } - - public ConnectionNotValidatedException(System.Exception ex) : base(ex) - { - } - - public ConnectionNotValidatedException(string reason) : base(reason) - { - } - - public ConnectionNotValidatedException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionNotValidatedException"; - } -} - -/// -/// This exception indicates that an unknown reply status has been received. -/// -public class UnknownReplyStatusException : ProtocolException -{ - public UnknownReplyStatusException() - { - } - - public UnknownReplyStatusException(System.Exception ex) : base(ex) - { - } - - public UnknownReplyStatusException(string reason) : base(reason) - { - } - - public UnknownReplyStatusException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::UnknownReplyStatusException"; - } -} - -/// -/// This exception indicates that the connection has been gracefully shut down by the server. -/// The operation call that -/// caused this exception has not been executed by the server. In most cases you will not get this exception, because -/// the client will automatically retry the operation call in case the server shut down the connection. However, if -/// upon retry the server shuts down the connection again, and the retry limit has been reached, then this exception is -/// propagated to the application code. -/// -public class CloseConnectionException : ProtocolException -{ - public CloseConnectionException() - { - } - - public CloseConnectionException(System.Exception ex) : base(ex) - { - } - - public CloseConnectionException(string reason) : base(reason) - { - } - - public CloseConnectionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CloseConnectionException"; - } -} - /// /// This exception is raised by an operation call if the application closes the connection locally using /// Connection.close. @@ -1018,88 +600,6 @@ public override string ice_id() } } -/// -/// This exception indicates that a message size is less than the minimum required size. -/// -public class IllegalMessageSizeException : ProtocolException -{ - public IllegalMessageSizeException() - { - } - - public IllegalMessageSizeException(System.Exception ex) : base(ex) - { - } - - public IllegalMessageSizeException(string reason) : base(reason) - { - } - - public IllegalMessageSizeException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::IllegalMessageSizeException"; - } -} - -/// -/// This exception indicates a problem with compressing or uncompressing data. -/// -public class CompressionException : ProtocolException -{ - public CompressionException() - { - } - - public CompressionException(System.Exception ex) : base(ex) - { - } - - public CompressionException(string reason) : base(reason) - { - } - - public CompressionException(string reason, System.Exception ex) : base(reason, ex) - { - } - - public override string ice_id() - { - return "::Ice::CompressionException"; - } -} - -/// -/// A datagram exceeds the configured size. -/// This exception is raised if a datagram exceeds the configured send or -/// receive buffer size, or exceeds the maximum payload size of a UDP packet (65507 bytes). -/// -public class DatagramLimitException : ProtocolException -{ - public DatagramLimitException() - { - } - - public DatagramLimitException(System.Exception ex) : base(ex) - { - } - - public DatagramLimitException(string reason) : base(reason) - { - } - - public DatagramLimitException(string reason, System.Exception ex) : base(reason, ex) - { - } - public override string ice_id() - { - return "::Ice::DatagramLimitException"; - } -} - /// /// This exception is raised if an unsupported feature is used. /// The unsupported feature string contains the name of the diff --git a/csharp/src/Ice/PluginManagerI.cs b/csharp/src/Ice/PluginManagerI.cs index 220290d31a3..df811f331bd 100644 --- a/csharp/src/Ice/PluginManagerI.cs +++ b/csharp/src/Ice/PluginManagerI.cs @@ -44,9 +44,7 @@ public void initializePlugins() { if (_initialized) { - InitializationException ex = new InitializationException(); - ex.reason = "plug-ins already initialized"; - throw ex; + throw new InitializationException("Plug-ins already initialized."); } // @@ -67,7 +65,7 @@ public void initializePlugins() } catch (System.Exception ex) { - throw new PluginInitializationException(String.Format("plugin `{0}' initialization failed", p.name), ex); + throw new PluginInitializationException($"Plugin '{p.name}' initialization failed.", ex); } initializedPlugins.Add(p.plugin); } @@ -254,9 +252,7 @@ public void loadPlugins(ref string[] cmdArgs) if (findPlugin(loadOrder[i]) is not null) { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "plug-in `" + loadOrder[i] + "' already loaded"; - throw e; + throw new PluginInitializationException($"Plug-in '{loadOrder[i]}' already loaded."); } string key = "Ice.Plugin." + loadOrder[i] + ".clr"; @@ -278,9 +274,7 @@ public void loadPlugins(ref string[] cmdArgs) } else { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "plug-in `" + loadOrder[i] + "' not defined"; - throw e; + throw new PluginInitializationException($"Plug-in '{loadOrder[i]}' not defined."); } } @@ -359,9 +353,7 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) } catch (Ice.UtilInternal.Options.BadQuote ex) { - PluginInitializationException e = new PluginInitializationException(); - e.reason = "invalid arguments for plug-in `" + name + "':\n" + ex.Message; - throw e; + throw new PluginInitializationException($"Invalid arguments for plug-in '{name}'.", ex); } Debug.Assert(args.Length > 0); @@ -411,9 +403,7 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) } if (sepPos == -1) { - PluginInitializationException e = new PluginInitializationException(); - e.reason = err + "invalid entry point format"; - throw e; + throw new PluginInitializationException($"{err}invalid entry point format"); } System.Reflection.Assembly? pluginAssembly = null; @@ -451,9 +441,7 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) } catch (System.Exception ex) { - PluginInitializationException e = new PluginInitializationException(); - e.reason = err + "unable to load assembly: `" + assemblyName + "': " + ex.ToString(); - throw e; + throw new PluginInitializationException($"{err}unable to load assembly '{assemblyName}'.", ex); } // @@ -466,9 +454,7 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) } catch (System.Exception ex) { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "GetType failed for `" + className + "'"; - throw e; + throw new PluginInitializationException($"{err}GetType failed for '{className}'.", ex); } try @@ -476,53 +462,32 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) pluginFactory = (PluginFactory)Ice.Internal.AssemblyUtil.createInstance(c); if (pluginFactory is null) { - PluginInitializationException e = new PluginInitializationException(); - e.reason = err + "can't find constructor for `" + className + "'"; - throw e; + throw new PluginInitializationException($"{err}can't find constructor for '{className}'."); } } - catch (InvalidCastException ex) - { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "InvalidCastException to Ice.PluginFactory"; - throw e; - } - catch (UnauthorizedAccessException ex) - { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "UnauthorizedAccessException: " + ex.ToString(); - throw e; - } catch (System.Exception ex) { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "System.Exception: " + ex.ToString(); - throw e; + throw new PluginInitializationException($"{err}SystemException", ex); } } - Plugin? plugin = null; + Plugin? plugin; try { plugin = pluginFactory.create(_communicator, name, args); } - catch (PluginInitializationException ex) + catch (PluginInitializationException) { - ex.reason = err + ex.reason; throw; } catch (System.Exception ex) { - PluginInitializationException e = new PluginInitializationException(ex); - e.reason = err + "System.Exception in factory.create: " + ex.ToString(); - throw e; + throw new PluginInitializationException($"{err}System.Exception in factory.create", ex); } if (plugin is null) { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = err + "factory.create returned null plug-in"; - throw ex; + throw new PluginInitializationException($"{err}factory.create returned null plug-in"); } _plugins.Add(new PluginInfo(name, plugin)); diff --git a/csharp/src/Ice/ThreadHookPlugin.cs b/csharp/src/Ice/ThreadHookPlugin.cs index 9ea0b0260dc..790da2831a2 100644 --- a/csharp/src/Ice/ThreadHookPlugin.cs +++ b/csharp/src/Ice/ThreadHookPlugin.cs @@ -23,9 +23,7 @@ public class ThreadHookPlugin : Plugin { if (communicator == null) { - PluginInitializationException ex = new PluginInitializationException(); - ex.reason = "Communicator cannot be null"; - throw ex; + throw new PluginInitializationException("Communicator cannot be null."); } Ice.Internal.Instance instance = communicator.instance; diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 48a2f962dd8..3b1a5df1cd7 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -830,9 +830,9 @@ public class AllTests : global::Test.AllTests cl20.ice_ping(); test(false); } - catch (Ice.UnsupportedEncodingException) + catch (MarshalException) { - // Server 2.0 endpoint doesn't support 1.1 version. + // Cannot marshal with the 2.0 encoding version. } string ref10 = "test -e 1.0:" + helper.getTestEndpoint(0); @@ -865,8 +865,7 @@ public class AllTests : global::Test.AllTests } catch (Ice.UnknownLocalException ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); + test(ex.unknown.Contains("MarshalException")); // encoding not supported } try @@ -886,8 +885,7 @@ public class AllTests : global::Test.AllTests } catch (Ice.UnknownLocalException ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.IndexOf("UnsupportedEncodingException") > 0); + test(ex.unknown.Contains("MarshalException")); // encoding not supported } output.WriteLine("ok"); @@ -901,7 +899,7 @@ public class AllTests : global::Test.AllTests cl20.ice_ping(); test(false); } - catch (Ice.UnsupportedProtocolException) + catch (FeatureNotSupportedException) { // Server 2.0 proxy doesn't support 1.0 version. } @@ -910,8 +908,8 @@ public class AllTests : global::Test.AllTests cl10 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref10)); cl10.ice_ping(); - // 1.3 isn't supported but since a 1.3 proxy supports 1.1, the - // call will use the 1.1 protocol + // 1.3 isn't supported but since a 1.3 proxy supports 1.0, the + // call will use the 1.0 protocol ref13 = "test -p 1.3:" + helper.getTestEndpoint(0); cl13 = Test.MyClassPrxHelper.uncheckedCast(communicator.stringToProxy(ref13)); cl13.ice_ping(); From edd5586cfa957270182be295ec1b922c692c3640 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 16:31:52 -0400 Subject: [PATCH 10/21] Checkpoint --- csharp/src/Ice/ConnectionI.cs | 6 +- csharp/src/Ice/Internal/ConnectionFactory.cs | 2 +- csharp/src/Ice/Internal/Instance.cs | 12 +- csharp/src/Ice/Internal/Network.cs | 26 +- csharp/src/Ice/Internal/NetworkProxy.cs | 4 +- csharp/src/Ice/Internal/Reference.cs | 14 +- csharp/src/Ice/Internal/RouterInfo.cs | 2 +- csharp/src/Ice/Internal/StreamSocket.cs | 4 +- csharp/src/Ice/Internal/UdpTransceiver.cs | 4 +- csharp/src/Ice/LocalExceptions.cs | 208 ++++++- csharp/src/Ice/ObjectAdapter.cs | 4 +- csharp/src/Ice/OldLocalExceptions.cs | 572 ------------------ csharp/src/Ice/Properties.cs | 4 +- csharp/src/Ice/SSL/SSLEngine.cs | 2 +- csharp/src/Ice/SSL/TransceiverI.cs | 14 +- csharp/test/Ice/background/AllTests.cs | 2 +- .../Ice/servantLocator/ServantLocatorAMDI.cs | 4 +- .../Ice/servantLocator/ServantLocatorI.cs | 4 +- 18 files changed, 245 insertions(+), 643 deletions(-) diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index af107df30ee..9e0b3c7ca55 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -142,7 +142,7 @@ internal void destroy(int reason) { case ObjectAdapterDeactivated: { - setState(StateClosing, new ObjectAdapterDeactivatedException()); + setState(StateClosing, new ObjectAdapterDeactivatedException(_adapter?.getName() ?? "")); break; } @@ -2297,9 +2297,7 @@ private int parseMessage(ref MessageInfo info) else { string lib = AssemblyUtil.isWindows ? "bzip2.dll" : "libbz2.so.1"; - FeatureNotSupportedException ex = new FeatureNotSupportedException(); - ex.unsupportedFeature = "Cannot uncompress compressed message: " + lib + " not found"; - throw ex; + throw new FeatureNotSupportedException($"Cannot uncompress compressed message: {lib} not found"); } } info.stream.pos(Protocol.headerSize); diff --git a/csharp/src/Ice/Internal/ConnectionFactory.cs b/csharp/src/Ice/Internal/ConnectionFactory.cs index 03cf20a40fd..57aeb3d1e2d 100644 --- a/csharp/src/Ice/Internal/ConnectionFactory.cs +++ b/csharp/src/Ice/Internal/ConnectionFactory.cs @@ -1552,7 +1552,7 @@ public IncomingConnectionFactory(Instance instance, EndpointI endpoint, Endpoint } else { - throw new Ice.SyscallException(ex); + throw new SyscallException(ex); } } } diff --git a/csharp/src/Ice/Internal/Instance.cs b/csharp/src/Ice/Internal/Instance.cs index b9bbe76f7d7..c7c76728952 100644 --- a/csharp/src/Ice/Internal/Instance.cs +++ b/csharp/src/Ice/Internal/Instance.cs @@ -655,11 +655,9 @@ internal void initialize(Ice.Communicator communicator, Ice.InitializationData i { outStream = System.IO.File.AppendText(stdOut); } - catch (System.IO.IOException ex) + catch (IOException ex) { - Ice.FileException fe = new Ice.FileException(ex); - fe.path = stdOut; - throw fe; + throw new FileException($"Cannot append to '{stdOut}'", ex); } outStream.AutoFlush = true; Console.Out.Close(); @@ -678,11 +676,9 @@ internal void initialize(Ice.Communicator communicator, Ice.InitializationData i { errStream = System.IO.File.AppendText(stdErr); } - catch (System.IO.IOException ex) + catch (IOException ex) { - Ice.FileException fe = new Ice.FileException(ex); - fe.path = stdErr; - throw fe; + throw new FileException($"Cannot append to '{stdErr}'", ex); } errStream.AutoFlush = true; Console.Error.Close(); diff --git a/csharp/src/Ice/Internal/Network.cs b/csharp/src/Ice/Internal/Network.cs index 573ccf00b9f..9e92e31cade 100644 --- a/csharp/src/Ice/Internal/Network.cs +++ b/csharp/src/Ice/Internal/Network.cs @@ -748,9 +748,7 @@ public static List getAddresses(string host, int port, int protocol, } else { - Ice.DNSException e = new Ice.DNSException(); - e.host = host; - throw e; + throw new DNSException(host); } } catch (FormatException) @@ -793,15 +791,11 @@ public static List getAddresses(string host, int port, int protocol, { goto repeatGetHostByName; } - Ice.DNSException e = new Ice.DNSException(ex); - e.host = host; - throw e; + throw new DNSException(host, ex); } catch (System.Exception ex) { - Ice.DNSException e = new Ice.DNSException(ex); - e.host = host; - throw e; + throw new DNSException(host, ex); } // @@ -809,9 +803,7 @@ public static List getAddresses(string host, int port, int protocol, // if (addresses.Count == 0) { - Ice.DNSException e = new Ice.DNSException(); - e.host = host; - throw e; + throw new DNSException(host); } return addresses; } @@ -854,15 +846,11 @@ public static IPAddress[] getLocalAddresses(int protocol, bool includeLoopback, { goto repeatGetHostByName; } - Ice.DNSException e = new Ice.DNSException(ex); - e.host = "0.0.0.0"; - throw e; + throw new DNSException("0.0.0.0", ex); } catch (System.Exception ex) { - Ice.DNSException e = new Ice.DNSException(ex); - e.host = "0.0.0.0"; - throw e; + throw new DNSException("0.0.0.0", ex); } return addresses.ToArray(); @@ -1200,7 +1188,7 @@ private static int // // The iface parameter must either be an IP address, an // index or the name of an interface. If it's an index we - // just return it. If it's an IP addess we search for an + // just return it. If it's an IP address we search for an // interface which has this IP address. If it's a name we // search an interface with this name. // diff --git a/csharp/src/Ice/Internal/NetworkProxy.cs b/csharp/src/Ice/Internal/NetworkProxy.cs index cfecb84ab93..9e673a8b974 100644 --- a/csharp/src/Ice/Internal/NetworkProxy.cs +++ b/csharp/src/Ice/Internal/NetworkProxy.cs @@ -74,11 +74,11 @@ public void beginWrite(EndPoint endpoint, Buffer buf) { if (!(endpoint is IPEndPoint)) { - throw new Ice.FeatureNotSupportedException("SOCKS4 does not support domain names"); + throw new FeatureNotSupportedException("SOCKS4 does not support domain names."); } else if (endpoint.AddressFamily != AddressFamily.InterNetwork) { - throw new Ice.FeatureNotSupportedException("SOCKS4 only supports IPv4 addresses"); + throw new FeatureNotSupportedException("SOCKS4 only supports IPv4 addresses."); } // diff --git a/csharp/src/Ice/Internal/Reference.cs b/csharp/src/Ice/Internal/Reference.cs index d185509c3c4..49d497febe0 100644 --- a/csharp/src/Ice/Internal/Reference.cs +++ b/csharp/src/Ice/Internal/Reference.cs @@ -659,7 +659,7 @@ internal override RequestHandler getRequestHandler() { if (_fixedConnection.endpoint().datagram()) { - throw new Ice.NoEndpointException(ToString()); + throw new NoEndpointException(new ObjectPrxHelper(this)); } break; } @@ -669,7 +669,7 @@ internal override RequestHandler getRequestHandler() { if (!_fixedConnection.endpoint().datagram()) { - throw new Ice.NoEndpointException(ToString()); + throw new NoEndpointException(new ObjectPrxHelper(this)); } break; } @@ -691,7 +691,7 @@ internal override RequestHandler getRequestHandler() } if (secure && !_fixedConnection.endpoint().secure()) { - throw new Ice.NoEndpointException(ToString()); + throw new NoEndpointException(new ObjectPrxHelper(this)); } _fixedConnection.throwException(); // Throw in case our connection is already destroyed. @@ -1188,7 +1188,7 @@ public void setEndpoints(EndpointI[] endpoints, bool cached) { if (endpoints.Length == 0) { - _cb.setException(new Ice.NoEndpointException(_ir.ToString())); + _cb.setException(new NoEndpointException(new ObjectPrxHelper(_ir))); return; } @@ -1225,7 +1225,7 @@ public void setException(Ice.LocalException exc) { throw exc; } - catch (Ice.NoEndpointException ex) + catch (NoEndpointException ex) { _cb.setException(ex); // No need to retry if there's no endpoints. } @@ -1268,7 +1268,7 @@ private void getConnectionNoRouterInfo(GetConnectionCallback callback) } else { - callback.setException(new Ice.NoEndpointException(ToString())); + callback.setException(new NoEndpointException(new ObjectPrxHelper(this))); } } @@ -1509,7 +1509,7 @@ protected void createConnection(EndpointI[] allEndpoints, GetConnectionCallback EndpointI[] endpoints = filterEndpoints(allEndpoints); if (endpoints.Length == 0) { - callback.setException(new Ice.NoEndpointException(ToString())); + callback.setException(new NoEndpointException(new ObjectPrxHelper(this))); return; } diff --git a/csharp/src/Ice/Internal/RouterInfo.cs b/csharp/src/Ice/Internal/RouterInfo.cs index a7eccb98215..19ea14012c6 100644 --- a/csharp/src/Ice/Internal/RouterInfo.cs +++ b/csharp/src/Ice/Internal/RouterInfo.cs @@ -104,7 +104,7 @@ public EndpointI[] getServerEndpoints() Ice.ObjectPrx serverProxy = _router.getServerProxy(); if (serverProxy == null) { - throw new Ice.NoEndpointException(); + throw new NoEndpointException("Router::getServerProxy returned a null proxy."); } serverProxy = serverProxy.ice_router(null); // The server proxy cannot be routed. diff --git a/csharp/src/Ice/Internal/StreamSocket.cs b/csharp/src/Ice/Internal/StreamSocket.cs index b58eb8de31c..12913269f60 100644 --- a/csharp/src/Ice/Internal/StreamSocket.cs +++ b/csharp/src/Ice/Internal/StreamSocket.cs @@ -382,10 +382,10 @@ private int read(ByteBuffer buf) } else if (Network.connectionLost(ex)) { - throw new Ice.ConnectionLostException(ex); + throw new ConnectionLostException(ex); } - throw new Ice.SocketException(ex); + throw new SocketException(ex); } } return read; diff --git a/csharp/src/Ice/Internal/UdpTransceiver.cs b/csharp/src/Ice/Internal/UdpTransceiver.cs index db1804bf615..6096eb32298 100644 --- a/csharp/src/Ice/Internal/UdpTransceiver.cs +++ b/csharp/src/Ice/Internal/UdpTransceiver.cs @@ -250,7 +250,7 @@ public int read(Buffer buf, ref bool hasMoreData) if (Network.connectionLost(e)) { - throw new Ice.ConnectionLostException(); + throw new ConnectionLostException(e); } else { @@ -259,7 +259,7 @@ public int read(Buffer buf, ref bool hasMoreData) } catch (System.Exception e) { - throw new Ice.SyscallException(e); + throw new SyscallException(e); } } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 36424736f0d..0250b80c139 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -129,6 +129,19 @@ public UnknownUserException(string message) public override string ice_id() => "::Ice::UnknownUserException"; } +/// +/// This exception is raised if the Communicator has been destroyed. +/// +public sealed class CommunicatorDestroyedException : LocalException +{ + public CommunicatorDestroyedException() + : base("Communicator destroyed.") + { + } + + public override string ice_id() => "::Ice::CommunicatorDestroyedException"; +} + /// /// This exception indicates that a connection was closed gracefully. /// @@ -155,6 +168,32 @@ public ConnectionIdleException(string message) public override string ice_id() => "::Ice::ConnectionIdleException"; } +/// +/// This exception is raised if an unsupported feature is used. +/// +public sealed class FeatureNotSupportedException : LocalException +{ + public FeatureNotSupportedException(string message) + : base(message) + { + } + + public override string ice_id() => "::Ice::FeatureNotSupportedException"; +} + +/// +/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. +/// +public sealed class FixedProxyException : LocalException +{ + public FixedProxyException() + : base("Cannot change the connection properties of a fixed proxy.") + { + } + + public override string ice_id() => "::Ice::FixedProxyException"; +} + /// /// This exception is raised when a failure occurs during initialization. /// @@ -168,13 +207,55 @@ public InitializationException(string message, System.Exception? innerException public override string ice_id() => "::Ice::InitializationException"; } +/// +/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. +/// +public sealed class InvocationCanceledException : LocalException +{ + public InvocationCanceledException() + : base("Invocation canceled.") + { + } + + public override string ice_id() => "::Ice::InvocationCanceledException"; +} + +/// +/// This exception is raised if no suitable endpoint is available. +/// +public sealed class NoEndpointException : LocalException +{ + public NoEndpointException(string message) + : base(message) + { + } + + public NoEndpointException(ObjectPrx proxy) + : base($"No suitable endpoint available for proxy '{proxy}'.") + { + } + + public override string ice_id() => "::Ice::NoEndpointException"; +} + +/// +/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. +/// +public sealed class ObjectAdapterDeactivatedException : LocalException +{ + public ObjectAdapterDeactivatedException(string name) + : base($"Object adapter '{name}' is deactivated.") + { + } + + public override string ice_id() => "::Ice::ObjectAdapterDeactivatedException"; +} + /// /// Reports a failure that occurred while parsing a string. /// public sealed class ParseException : LocalException { - public string unknown => Message; - public ParseException(string message, System.Exception? innerException = null) : base(message, innerException) { @@ -196,6 +277,35 @@ public PluginInitializationException(string message, System.Exception? innerExce public override string ice_id() => "::Ice::PluginInitializationException"; } +/// +/// This exception indicates a failure in a security subsystem. +/// +public sealed class SecurityException : LocalException +{ + public SecurityException(string message, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::SecurityException"; +} + +/// +/// The operation can only be invoked with a two-way request. +/// This exception is raised if an attempt is made to invoke an operation with ice_oneway, ice_batchOneway, +/// ice_datagram, or ice_batchDatagram and the operation has a return value, out-parameters, or an exception +/// specification. +/// +public sealed class TwowayOnlyException : LocalException +{ + public TwowayOnlyException(string operation) + : base($"Cannot invoke operation '{operation}' with a oneway, batchOneway, datagram, or batchDatagram proxy.") + { + } + + public override string ice_id() => "::Ice::TwowayOnlyException"; +} + /// /// The base class for Ice protocol exceptions. /// @@ -301,3 +411,97 @@ public InvocationTimeoutException() public override string ice_id() => "::Ice::InvocationTimeoutException"; } + +/// +/// This exception is raised if a system error occurred in the server or client process. +/// +public class SyscallException : LocalException +{ + public SyscallException(string? message = null, System.Exception? innerException = null) + : base(message, innerException) + { + } + + public SyscallException(System.Exception innerException) + : base(innerException) + { + } + + public override string ice_id() => "::Ice::SyscallException"; +} + +/// +/// This exception indicates a DNS problem. +/// +public sealed class DNSException : SyscallException +{ + public DNSException(string host, System.Exception? innerException = null) + : base($"Cannot resolve host '{host}'", innerException) + { + } + + public override string ice_id() => "::Ice::DNSException"; +} + +/// +/// This exception indicates socket errors. +/// +public class SocketException : SyscallException +{ + public SocketException(System.Exception? innerException = null) + : base(message: null, innerException) + { + } + + public override string ice_id() => "::Ice::SocketException"; +} + +/// This exception indicates file errors. +public sealed class FileException : SyscallException +{ + public FileException(string message, System.Exception innerException) + : base(message, innerException) + { + } + + public override string ice_id() => "::Ice::FileException"; +} + +/// +/// This exception indicates connection failures. +/// +public class ConnectFailedException : SocketException +{ + public ConnectFailedException(System.Exception? innerException = null) + : base(innerException) + { + } + + public override string ice_id() => "::Ice::ConnectFailedException"; +} + +/// +/// This exception indicates a connection failure for which the server host actively refuses a connection. +/// +public sealed class ConnectionRefusedException : ConnectFailedException +{ + public ConnectionRefusedException(System.Exception? innerException = null) + : base(innerException) + { + } + + public override string ice_id() => "::Ice::ConnectionRefusedException"; +} + +/// +/// This exception indicates a lost connection. +/// +public sealed class ConnectionLostException : SocketException +{ + public ConnectionLostException(System.Exception? innerException = null) + : base(innerException) + { + } + + public override string ice_id() => "::Ice::ConnectionLostException"; +} diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index e7988035ba0..85c2529a5b3 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1366,9 +1366,7 @@ private void checkForDeactivation() { if (_state >= StateDeactivating) { - ObjectAdapterDeactivatedException ex = new ObjectAdapterDeactivatedException(); - ex.name = getName(); - throw ex; + throw new ObjectAdapterDeactivatedException(getName()); } } diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs index 60f51827c22..20763345d9a 100644 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ b/csharp/src/Ice/OldLocalExceptions.cs @@ -24,11 +24,6 @@ public AlreadyRegisteredException() _initDM(); } - public AlreadyRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } - private void _initDM(string kindOfObject, string id) { this.kindOfObject = kindOfObject; @@ -40,12 +35,6 @@ public AlreadyRegisteredException(string kindOfObject, string id) _initDM(kindOfObject, id); } - [System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.7.10")] - public AlreadyRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } - public override string ice_id() { return "::Ice::AlreadyRegisteredException"; @@ -91,124 +80,12 @@ public NotRegisteredException(string kindOfObject, string id) _initDM(kindOfObject, id); } - public NotRegisteredException(string kindOfObject, string id, System.Exception ex) : base(ex) - { - _initDM(kindOfObject, id); - } public override string ice_id() { return "::Ice::NotRegisteredException"; } } -/// -/// The operation can only be invoked with a twoway request. -/// This exception is raised if an attempt is made to invoke -/// an operation with ice_oneway, ice_batchOneway, ice_datagram, or -/// ice_batchDatagram and the operation has a return value, out-parameters, or an exception specification. -/// -public class TwowayOnlyException : LocalException -{ - public string operation; - - private void _initDM() - { - this.operation = ""; - } - - public TwowayOnlyException() - { - _initDM(); - } - - public TwowayOnlyException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string operation) - { - this.operation = operation; - } - - public TwowayOnlyException(string operation) - { - _initDM(operation); - } - - public TwowayOnlyException(string operation, System.Exception ex) : base(ex) - { - _initDM(operation); - } - - public override string ice_id() - { - return "::Ice::TwowayOnlyException"; - } -} - -/// -/// This exception is raised if the Communicator has been destroyed. -/// -public class CommunicatorDestroyedException : LocalException -{ - public CommunicatorDestroyedException() - { - } - - public CommunicatorDestroyedException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::CommunicatorDestroyedException"; - } -} - -/// -/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. -/// -public class ObjectAdapterDeactivatedException : LocalException -{ - public string name; - - private void _initDM() - { - this.name = ""; - } - - public ObjectAdapterDeactivatedException() - { - _initDM(); - } - - public ObjectAdapterDeactivatedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string name) - { - this.name = name; - } - - public ObjectAdapterDeactivatedException(string name) - { - _initDM(name); - } - - public ObjectAdapterDeactivatedException(string name, System.Exception ex) : base(ex) - { - _initDM(name); - } - - public override string ice_id() - { - return "::Ice::ObjectAdapterDeactivatedException"; - } -} - /// /// This exception is raised if an ObjectAdapter cannot be activated. /// This happens if the Locator @@ -228,335 +105,12 @@ public ObjectAdapterIdInUseException() _initDM(); } - public ObjectAdapterIdInUseException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string id) - { - this.id = id; - } - - public ObjectAdapterIdInUseException(string id) - { - _initDM(id); - } - - public ObjectAdapterIdInUseException(string id, System.Exception ex) : base(ex) - { - _initDM(id); - } - public override string ice_id() { return "::Ice::ObjectAdapterIdInUseException"; } } -/// -/// This exception is raised if no suitable endpoint is available. -/// -public class NoEndpointException : LocalException -{ - public string proxy; - - private void _initDM() - { - this.proxy = ""; - } - - public NoEndpointException() - { - _initDM(); - } - - public NoEndpointException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string proxy) - { - this.proxy = proxy; - } - - public NoEndpointException(string proxy) - { - _initDM(proxy); - } - - public NoEndpointException(string proxy, System.Exception ex) : base(ex) - { - _initDM(proxy); - } - - public override string ice_id() - { - return "::Ice::NoEndpointException"; - } -} - -/// -/// This exception is raised if a system error occurred in the server or client process. -/// There are many possible causes -/// for such a system exception. For details on the cause, SyscallException.error should be inspected. -/// -public class SyscallException : LocalException -{ - public int error; - - private void _initDM() - { - this.error = 0; - } - - public SyscallException() - { - _initDM(); - } - - public SyscallException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error) - { - this.error = error; - } - - public SyscallException(int error) - { - _initDM(error); - } - - public SyscallException(int error, System.Exception ex) : base(ex) - { - _initDM(error); - } - - public override string ice_id() - { - return "::Ice::SyscallException"; - } -} - -/// -/// This exception indicates socket errors. -/// -public class SocketException : SyscallException -{ - public SocketException() - { - } - - public SocketException(System.Exception ex) : base(ex) - { - } - - public SocketException(int error) : base(error) - { - } - - public SocketException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::SocketException"; - } -} - -/// This exception indicates file errors. -public class FileException : SyscallException -{ - public string path; - - private void _initDM() - { - this.path = ""; - } - - public FileException() - { - _initDM(); - } - - public FileException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string path) - { - this.path = path; - } - - public FileException(int error, string path) : base(error) - { - _initDM(path); - } - - public FileException(int error, string path, System.Exception ex) : base(error, ex) - { - _initDM(path); - } - - public override string ice_id() - { - return "::Ice::FileException"; - } -} - -/// -/// This exception indicates connection failures. -/// -public class ConnectFailedException : SocketException -{ - public ConnectFailedException() - { - } - - public ConnectFailedException(System.Exception ex) : base(ex) - { - } - - public ConnectFailedException(int error) : base(error) - { - } - - public ConnectFailedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectFailedException"; - } -} - -/// -/// This exception indicates a connection failure for which the server host actively refuses a connection. -/// -public class ConnectionRefusedException : ConnectFailedException -{ - public ConnectionRefusedException() - { - } - - public ConnectionRefusedException(System.Exception ex) : base(ex) - { - } - - public ConnectionRefusedException(int error) : base(error) - { - } - - public ConnectionRefusedException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionRefusedException"; - } -} - -/// -/// This exception indicates a lost connection. -/// -public class ConnectionLostException : SocketException -{ - public ConnectionLostException() - { - } - - public ConnectionLostException(System.Exception ex) : base(ex) - { - } - - public ConnectionLostException(int error) : base(error) - { - } - - public ConnectionLostException(int error, System.Exception ex) : base(error, ex) - { - } - - public override string ice_id() - { - return "::Ice::ConnectionLostException"; - } -} - -/// -/// This exception indicates a DNS problem. -/// For details on the cause, DNSException.error should be inspected. -/// -public class DNSException : LocalException -{ - public int error; - public string host; - - private void _initDM() - { - this.error = 0; - this.host = ""; - } - - public DNSException() - { - _initDM(); - } - - public DNSException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(int error, string host) - { - this.error = error; - this.host = host; - } - - public DNSException(int error, string host) - { - _initDM(error, host); - } - - public DNSException(int error, string host, System.Exception ex) : base(ex) - { - _initDM(error, host); - } - - public override string ice_id() - { - return "::Ice::DNSException"; - } -} - -/// -/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. -/// -public class InvocationCanceledException : LocalException -{ - public InvocationCanceledException() - { - } - - public InvocationCanceledException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::InvocationCanceledException"; - } -} - /// /// This exception is raised by an operation call if the application closes the connection locally using /// Connection.close. @@ -565,20 +119,6 @@ public class ConnectionManuallyClosedException : LocalException { public bool graceful; - private void _initDM() - { - } - - public ConnectionManuallyClosedException() - { - _initDM(); - } - - public ConnectionManuallyClosedException(System.Exception ex) : base(ex) - { - _initDM(); - } - private void _initDM(bool graceful) { this.graceful = graceful; @@ -589,120 +129,8 @@ public ConnectionManuallyClosedException(bool graceful) _initDM(graceful); } - public ConnectionManuallyClosedException(bool graceful, System.Exception ex) : base(ex) - { - _initDM(graceful); - } - public override string ice_id() { return "::Ice::ConnectionManuallyClosedException"; } } - -/// -/// This exception is raised if an unsupported feature is used. -/// The unsupported feature string contains the name of the -/// unsupported feature. -/// -public class FeatureNotSupportedException : LocalException -{ - public string unsupportedFeature; - - private void _initDM() - { - this.unsupportedFeature = ""; - } - - public FeatureNotSupportedException() - { - _initDM(); - } - - public FeatureNotSupportedException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string unsupportedFeature) - { - this.unsupportedFeature = unsupportedFeature; - } - - public FeatureNotSupportedException(string unsupportedFeature) - { - _initDM(unsupportedFeature); - } - - public FeatureNotSupportedException(string unsupportedFeature, System.Exception ex) : base(ex) - { - _initDM(unsupportedFeature); - } - - public override string ice_id() - { - return "::Ice::FeatureNotSupportedException"; - } -} - -/// -/// This exception indicates a failure in a security subsystem, such as the IceSSL plug-in. -/// -public class SecurityException : LocalException -{ - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public SecurityException() - { - _initDM(); - } - - public SecurityException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string reason) - { - this.reason = reason; - } - - public SecurityException(string reason) - { - _initDM(reason); - } - - public SecurityException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::Ice::SecurityException"; - } -} - -/// -/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. -/// -public class FixedProxyException : LocalException -{ - public FixedProxyException() - { - } - - public FixedProxyException(System.Exception ex) : base(ex) - { - } - - public override string ice_id() - { - return "::Ice::FixedProxyException"; - } -} diff --git a/csharp/src/Ice/Properties.cs b/csharp/src/Ice/Properties.cs index df8caeb7e4f..af2ed9e3522 100644 --- a/csharp/src/Ice/Properties.cs +++ b/csharp/src/Ice/Properties.cs @@ -477,9 +477,7 @@ public void load(string file) } catch (IOException ex) { - var fe = new FileException(ex); - fe.path = file; - throw fe; + throw new FileException($"Cannot read '{file}'", ex); } } diff --git a/csharp/src/Ice/SSL/SSLEngine.cs b/csharp/src/Ice/SSL/SSLEngine.cs index 3d02eae781e..29430f19074 100644 --- a/csharp/src/Ice/SSL/SSLEngine.cs +++ b/csharp/src/Ice/SSL/SSLEngine.cs @@ -195,7 +195,7 @@ internal void verifyPeer(ConnectionInfo info, string description) _logger.trace(_securityTraceCategory, msg); } - throw new Ice.SecurityException($"IceSSL: {msg}"); + throw new SecurityException($"IceSSL: {msg}"); } } diff --git a/csharp/src/Ice/SSL/TransceiverI.cs b/csharp/src/Ice/SSL/TransceiverI.cs index c99c4229a28..ab11614cab9 100644 --- a/csharp/src/Ice/SSL/TransceiverI.cs +++ b/csharp/src/Ice/SSL/TransceiverI.cs @@ -393,15 +393,13 @@ private bool startAuthenticate(Ice.Internal.AsyncCallback callback, object state if (Ice.Internal.Network.connectionLost(ex)) { // This situation occurs when connectToSelf is called; the "remote" end closes the socket immediately. - throw new Ice.ConnectionLostException(); + throw new ConnectionLostException(ex); } - throw new Ice.SocketException(ex); + throw new SocketException(ex); } catch (AuthenticationException ex) { - var e = new Ice.SecurityException(ex); - e.reason = ex.Message; - throw e; + throw new SecurityException("Authentication failure.", ex); } catch (Exception ex) { @@ -437,11 +435,9 @@ private void finishAuthenticate() } catch (AuthenticationException ex) { - var e = new Ice.SecurityException(ex); - e.reason = ex.Message; - throw e; + throw new SecurityException("Authentication failure.", ex); } - catch (Exception ex) + catch (System.Exception ex) { throw new Ice.SyscallException(ex); } diff --git a/csharp/test/Ice/background/AllTests.cs b/csharp/test/Ice/background/AllTests.cs index 325c2ff403e..1a59b2da05e 100644 --- a/csharp/test/Ice/background/AllTests.cs +++ b/csharp/test/Ice/background/AllTests.cs @@ -265,7 +265,7 @@ private static async Task connectTests(Configuration configuration, Test.Backgro { if (i == 0 || i == 2) { - configuration.connectorsException(new Ice.DNSException()); + configuration.connectorsException(new Ice.DNSException("dummy")); } else { diff --git a/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs b/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs index adf5a3e096a..04aecec7d40 100644 --- a/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs +++ b/csharp/test/Ice/servantLocator/ServantLocatorAMDI.cs @@ -132,9 +132,7 @@ private void exception(Ice.Current current) } else if (current.operation == "localException") { - var ex = new Ice.SocketException(); - ex.error = 0; - throw ex; + throw new Ice.SocketException(); } else if (current.operation == "csException") { diff --git a/csharp/test/Ice/servantLocator/ServantLocatorI.cs b/csharp/test/Ice/servantLocator/ServantLocatorI.cs index bf8ecc624ad..1450019a575 100644 --- a/csharp/test/Ice/servantLocator/ServantLocatorI.cs +++ b/csharp/test/Ice/servantLocator/ServantLocatorI.cs @@ -130,9 +130,7 @@ private void exception(Ice.Current current) } else if (current.operation == "localException") { - var ex = new Ice.SocketException(); - ex.error = 0; - throw ex; + throw new Ice.SocketException(); } else if (current.operation == "csException") { From d48a9da5b8086782f1f6be59142d18cfa80c70c0 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 17:47:25 -0400 Subject: [PATCH 11/21] Cleanup --- CHANGELOG-3.8.md | 1 + csharp/src/Ice/Connection.cs | 2 +- csharp/src/Ice/ConnectionI.cs | 24 +++- csharp/src/Ice/Internal/LocatorInfo.cs | 16 +-- .../src/Ice/Internal/ObjectAdapterFactory.cs | 5 +- .../src/Ice/Internal/RequestHandlerCache.cs | 5 +- csharp/src/Ice/Internal/ServantManager.cs | 45 ++---- .../src/Ice/Internal/ValueFactoryManager.cs | 5 +- csharp/src/Ice/LocalExceptions.cs | 107 ++++++++++---- csharp/src/Ice/ObjectAdapter.cs | 21 +-- csharp/src/Ice/OldLocalExceptions.cs | 136 ------------------ csharp/src/Ice/PluginManagerI.cs | 10 +- csharp/test/Ice/ami/AllTests.cs | 16 +-- csharp/test/Ice/timeout/AllTests.cs | 4 +- 14 files changed, 144 insertions(+), 253 deletions(-) delete mode 100644 csharp/src/Ice/OldLocalExceptions.cs diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index 888fc2ee6b2..5dbde7c08c0 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -63,6 +63,7 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG |-------------------------------------|----------------------------| | BadMagicException | ProtocolException (base) | | CompressionException | ProtocolException (base) | + | ConnectionManuallyClosedException | ConnectionClosedException | | ConnectionNotValidatedException | ProtocolException (base) | | EncapsulationException | MarshalException (base) | | EndpointParseException | ParseException | diff --git a/csharp/src/Ice/Connection.cs b/csharp/src/Ice/Connection.cs index 85ced020b5c..388c2526dd5 100644 --- a/csharp/src/Ice/Connection.cs +++ b/csharp/src/Ice/Connection.cs @@ -189,7 +189,7 @@ System.Threading.Tasks.Task heartbeatAsync( /// Throw an exception indicating the reason for connection closure. /// For example, /// CloseConnectionException is raised if the connection was closed gracefully, whereas - /// ConnectionManuallyClosedException is raised if the connection was manually closed by + /// ConnectionClosedException is raised if the connection was manually closed by /// the application. This operation does nothing if the connection is not yet closed. /// void throwException(); diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 9e0b3c7ca55..29799e75bd5 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -161,11 +161,18 @@ public void close(ConnectionClose mode) { if (mode == ConnectionClose.Forcefully) { - setState(StateClosed, new ConnectionManuallyClosedException(false)); + setState(StateClosed, + new ConnectionClosedException( + "Connection close forcefully by the application.", + closedByApplication: true)); } else if (mode == ConnectionClose.Gracefully) { - setState(StateClosing, new ConnectionManuallyClosedException(true)); + setState( + StateClosing, + new ConnectionClosedException( + "Connection close gracefully by the application.", + closedByApplication: true)); } else { @@ -179,7 +186,11 @@ public void close(ConnectionClose mode) Monitor.Wait(this); } - setState(StateClosing, new ConnectionManuallyClosedException(true)); + setState( + StateClosing, + new ConnectionClosedException( + "Connection close gracefully by the application.", + closedByApplication: true)); } } } @@ -1256,7 +1267,6 @@ private void finish() // Trace the cause of unexpected connection closures // if (!(_exception is CloseConnectionException || - _exception is ConnectionManuallyClosedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || @@ -1597,7 +1607,6 @@ private void setState(int state, LocalException ex) // Don't warn about certain expected exceptions. // if (!(_exception is CloseConnectionException || - _exception is ConnectionManuallyClosedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || @@ -1760,7 +1769,6 @@ private void setState(int state) if (_observer is not null && state == StateClosed && _exception is not null) { if (!(_exception is CloseConnectionException || - _exception is ConnectionManuallyClosedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || @@ -2628,7 +2636,9 @@ private void inactivityCheck(System.Threading.Timer inactivityTimer) { setState( StateClosing, - new ConnectionClosedException("Connection closed because it remained inactive for longer than the inactivity timeout.")); + new ConnectionClosedException( + "Connection closed because it remained inactive for longer than the inactivity timeout.", + closedByApplication: false)); } } // Else this timer was already canceled and disposed. Nothing to do. diff --git a/csharp/src/Ice/Internal/LocatorInfo.cs b/csharp/src/Ice/Internal/LocatorInfo.cs index fdd5ace04b9..92e6faa0838 100644 --- a/csharp/src/Ice/Internal/LocatorInfo.cs +++ b/csharp/src/Ice/Internal/LocatorInfo.cs @@ -449,7 +449,7 @@ private void getEndpointsException(Reference @ref, System.Exception exc) { throw exc; } - catch (Ice.AdapterNotFoundException ex) + catch (Ice.AdapterNotFoundException) { Instance instance = @ref.getInstance(); if (instance.traceLevels().location >= 1) @@ -460,12 +460,9 @@ private void getEndpointsException(Reference @ref, System.Exception exc) instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); } - Ice.NotRegisteredException e = new Ice.NotRegisteredException(ex); - e.kindOfObject = "object adapter"; - e.id = @ref.getAdapterId(); - throw e; + throw new NotRegisteredException("object adapter", @ref.getAdapterId()); } - catch (Ice.ObjectNotFoundException ex) + catch (Ice.ObjectNotFoundException) { Instance instance = @ref.getInstance(); if (instance.traceLevels().location >= 1) @@ -476,10 +473,9 @@ private void getEndpointsException(Reference @ref, System.Exception exc) instance.initializationData().logger.trace(instance.traceLevels().locationCat, s.ToString()); } - Ice.NotRegisteredException e = new Ice.NotRegisteredException(ex); - e.kindOfObject = "object"; - e.id = Ice.Util.identityToString(@ref.getIdentity(), instance.toStringMode()); - throw e; + throw new NotRegisteredException( + "object", + Ice.Util.identityToString(@ref.getIdentity(), instance.toStringMode())); } catch (Ice.NotRegisteredException) { diff --git a/csharp/src/Ice/Internal/ObjectAdapterFactory.cs b/csharp/src/Ice/Internal/ObjectAdapterFactory.cs index 594e4149362..33e54358e76 100644 --- a/csharp/src/Ice/Internal/ObjectAdapterFactory.cs +++ b/csharp/src/Ice/Internal/ObjectAdapterFactory.cs @@ -140,10 +140,7 @@ public Ice.ObjectAdapter createObjectAdapter( { if (_adapterNamesInUse.Contains(name)) { - Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); - ex.kindOfObject = "object adapter"; - ex.id = name; - throw ex; + throw new AlreadyRegisteredException("object adapter", name); } _adapterNamesInUse.Add(name); } diff --git a/csharp/src/Ice/Internal/RequestHandlerCache.cs b/csharp/src/Ice/Internal/RequestHandlerCache.cs index fb54673d752..9f06ebfae2b 100644 --- a/csharp/src/Ice/Internal/RequestHandlerCache.cs +++ b/csharp/src/Ice/Internal/RequestHandlerCache.cs @@ -235,11 +235,12 @@ private static int checkRetryAfterException(Ice.LocalException ex, Reference @re // // Don't retry if the communicator is destroyed, object adapter is deactivated, - // or connection is manually closed. + // or connection is closed by the application. // if (ex is Ice.CommunicatorDestroyedException || ex is Ice.ObjectAdapterDeactivatedException || - ex is Ice.ConnectionManuallyClosedException) + (ex is Ice.ConnectionClosedException connectionClosedException && + connectionClosedException.closedByApplication)) { throw ex; } diff --git a/csharp/src/Ice/Internal/ServantManager.cs b/csharp/src/Ice/Internal/ServantManager.cs index 5466a1b44ea..7b000cdd656 100644 --- a/csharp/src/Ice/Internal/ServantManager.cs +++ b/csharp/src/Ice/Internal/ServantManager.cs @@ -85,14 +85,12 @@ internal void addServant(Object servant, Identity ident, string facet) { if (m.ContainsKey(facet)) { - AlreadyRegisteredException ex = new AlreadyRegisteredException(); - ex.id = Ice.Util.identityToString(ident, _instance.toStringMode()); - ex.kindOfObject = "servant"; + string id = Ice.Util.identityToString(ident, _instance.toStringMode()); if (facet.Length > 0) { - ex.id += " -f " + UtilInternal.StringUtil.escapeString(facet, "", _instance.toStringMode()); + id += " -f " + UtilInternal.StringUtil.escapeString(facet, "", _instance.toStringMode()); } - throw ex; + throw new AlreadyRegisteredException("servant", id); } } else @@ -111,10 +109,7 @@ internal void addDefaultServant(Object servant, string category) { if (_defaultServantMap.TryGetValue(category, out Object? obj)) { - AlreadyRegisteredException ex = new AlreadyRegisteredException(); - ex.kindOfObject = "default servant"; - ex.id = category; - throw ex; + throw new AlreadyRegisteredException("default servant", category); } _defaultServantMap[category] = servant; @@ -132,14 +127,12 @@ internal Object removeServant(Identity ident, string facet) Object? obj = null; if (m is null || !m.TryGetValue(facet, out Object? value)) { - NotRegisteredException ex = new NotRegisteredException(); - ex.id = Ice.Util.identityToString(ident, _instance.toStringMode()); - ex.kindOfObject = "servant"; + string id = Ice.Util.identityToString(ident, _instance.toStringMode()); if (facet.Length > 0) { - ex.id += " -f " + UtilInternal.StringUtil.escapeString(facet, "", _instance.toStringMode()); + id += " -f " + UtilInternal.StringUtil.escapeString(facet, "", _instance.toStringMode()); } - throw ex; + throw new NotRegisteredException("servant", id); } obj = value; m.Remove(facet); @@ -158,10 +151,7 @@ internal Object removeDefaultServant(string category) { if (!_defaultServantMap.TryGetValue(category, out Object? obj)) { - NotRegisteredException ex = new NotRegisteredException(); - ex.kindOfObject = "default servant"; - ex.id = category; - throw ex; + throw new NotRegisteredException("default servant", category); } _defaultServantMap.Remove(category); @@ -175,10 +165,7 @@ internal Dictionary removeAllFacets(Identity ident) { if (!_servantMapMap.TryGetValue(ident, out Dictionary? m)) { - NotRegisteredException ex = new NotRegisteredException(); - ex.id = Ice.Util.identityToString(ident, _instance.toStringMode()); - ex.kindOfObject = "servant"; - throw ex; + throw new NotRegisteredException("servant", Ice.Util.identityToString(ident, _instance.toStringMode())); } _servantMapMap.Remove(ident); @@ -246,10 +233,9 @@ internal void addServantLocator(ServantLocator locator, string category) { if (_locatorMap.TryGetValue(category, out ServantLocator? l)) { - AlreadyRegisteredException ex = new AlreadyRegisteredException(); - ex.id = UtilInternal.StringUtil.escapeString(category, "", _instance.toStringMode()); - ex.kindOfObject = "servant locator"; - throw ex; + throw new AlreadyRegisteredException( + "servant locator", + UtilInternal.StringUtil.escapeString(category, "", _instance.toStringMode())); } _locatorMap[category] = locator; @@ -262,10 +248,9 @@ internal ServantLocator removeServantLocator(string category) { if (!_locatorMap.TryGetValue(category, out ServantLocator? l)) { - NotRegisteredException ex = new NotRegisteredException(); - ex.id = UtilInternal.StringUtil.escapeString(category, "", _instance.toStringMode()); - ex.kindOfObject = "servant locator"; - throw ex; + throw new NotRegisteredException( + "servant locator", + UtilInternal.StringUtil.escapeString(category, "", _instance.toStringMode())); } _locatorMap.Remove(category); return l; diff --git a/csharp/src/Ice/Internal/ValueFactoryManager.cs b/csharp/src/Ice/Internal/ValueFactoryManager.cs index 5baf53ab645..d8c0b2e358d 100644 --- a/csharp/src/Ice/Internal/ValueFactoryManager.cs +++ b/csharp/src/Ice/Internal/ValueFactoryManager.cs @@ -10,10 +10,7 @@ public void add(Ice.ValueFactory factory, string id) { if (_factoryMap.ContainsKey(id)) { - Ice.AlreadyRegisteredException ex = new Ice.AlreadyRegisteredException(); - ex.id = id; - ex.kindOfObject = "value factory"; - throw ex; + throw new AlreadyRegisteredException("value factory", id); } _factoryMap[id] = factory; } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 0250b80c139..ebddfd5d300 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -14,16 +14,15 @@ namespace Ice; /// public class RequestFailedException : LocalException { - public Identity id; - public string facet; - public string operation; - - protected RequestFailedException( - Identity id, - string facet, - string operation, - System.Exception? innerException = null) - : base(message: null, innerException) + public Identity id { get; set; } + public string facet { get; set; } + public string operation { get; set; } + + // We can't set the message in the constructor because id/facet/operation can be set after construction. + public override string Message => + $"{base.Message} id = '{Util.identityToString(id)}', facet = '{facet}', operation = '{operation}'"; + + protected RequestFailedException(Identity id, string facet, string operation) { this.id = id; this.facet = facet; @@ -36,13 +35,13 @@ protected RequestFailedException( /// public sealed class ObjectNotExistException : RequestFailedException { - public ObjectNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) + public ObjectNotExistException() + : base(new Identity(), "", "") { } - public ObjectNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) + public ObjectNotExistException(Identity id, string facet, string operation) + : base(id, facet, operation) { } @@ -54,13 +53,13 @@ public ObjectNotExistException(Identity id, string facet, string operation, Syst /// public sealed class FacetNotExistException : RequestFailedException { - public FacetNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) + public FacetNotExistException() + : base(new Identity(), "", "") { } - public FacetNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) + public FacetNotExistException(Identity id, string facet, string operation) + : base(id, facet, operation) { } @@ -73,13 +72,13 @@ public FacetNotExistException(Identity id, string facet, string operation, Syste /// public sealed class OperationNotExistException : RequestFailedException { - public OperationNotExistException(System.Exception? innerException = null) - : base(new Identity(), "", "", innerException) + public OperationNotExistException() + : base(new Identity(), "", "") { } - public OperationNotExistException(Identity id, string facet, string operation, System.Exception? innerException = null) - : base(id, facet, operation, innerException) + public OperationNotExistException(Identity id, string facet, string operation) + : base(id, facet, operation) { } @@ -147,10 +146,11 @@ public CommunicatorDestroyedException() /// public sealed class ConnectionClosedException : LocalException { - public ConnectionClosedException(string message) - : base(message, innerException: null) - { - } + public bool closedByApplication { get; } + + public ConnectionClosedException(string message, bool closedByApplication) + : base(message, innerException: null) => + this.closedByApplication = closedByApplication; public override string ice_id() => "::Ice::ConnectionClosedException"; } @@ -505,3 +505,58 @@ public ConnectionLostException(System.Exception? innerException = null) public override string ice_id() => "::Ice::ConnectionLostException"; } + +/// +/// This exception is raised if an ObjectAdapter cannot be activated. +/// This happens if the Locator detects another active ObjectAdapter with the same adapter ID. +/// +public class ObjectAdapterIdInUseException : LocalException +{ + public ObjectAdapterIdInUseException(string adapterId) + : base($"An object adapter with adapter ID '{adapterId}' is already active.") + { + } + + public override string ice_id() => "::Ice::ObjectAdapterIdInUseException"; +} + +/// +/// An attempt was made to register something more than once with the Ice run time. +/// This exception is raised if an attempt is made to register a servant, servant locator, facet, value factory, +/// plug-in, object adapter (etc.) more than once for the same ID. +/// +public sealed class AlreadyRegisteredException : LocalException +{ + public string kindOfObject { get; } + public string id { get; } + + public AlreadyRegisteredException(string kindOfObject, string id) + : base($"Another {kindOfObject} is already registered with ID '{id}'.") + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public override string ice_id() => "::Ice::AlreadyRegisteredException"; +} + +/// +/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. +/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, +/// object adapter (etc.) that is not currently registered. It's also raised if the Ice locator can't find an object or +/// object adapter when resolving an indirect proxy or when an object adapter is activated. +/// +public sealed class NotRegisteredException : LocalException +{ + public string kindOfObject { get; } + public string id { get; } + + public NotRegisteredException(string kindOfObject, string id) + : base($"No {kindOfObject} is registered with ID '{id}'.") + { + this.kindOfObject = kindOfObject; + this.id = id; + } + + public override string ice_id() => "::Ice::NotRegisteredException"; +} diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index 85c2529a5b3..c263c14836b 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -1256,10 +1256,9 @@ internal ObjectAdapter( // if (_routerInfo.getAdapter() is not null) { - AlreadyRegisteredException ex = new AlreadyRegisteredException(); - ex.kindOfObject = "object adapter with router"; - ex.id = Util.identityToString(router.ice_getIdentity(), _instance.toStringMode()); - throw ex; + throw new AlreadyRegisteredException( + "object adapter with router", + Util.identityToString(router.ice_getIdentity(), _instance.toStringMode())); } // @@ -1561,10 +1560,7 @@ private void updateLocatorRegistry(LocatorInfo? locatorInfo, ObjectPrx? proxy) _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); } - NotRegisteredException ex1 = new NotRegisteredException(); - ex1.kindOfObject = "object adapter"; - ex1.id = _id; - throw ex1; + throw new NotRegisteredException("object adapter", _id); } catch (InvalidReplicaGroupIdException) { @@ -1576,10 +1572,7 @@ private void updateLocatorRegistry(LocatorInfo? locatorInfo, ObjectPrx? proxy) _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); } - NotRegisteredException ex1 = new NotRegisteredException(); - ex1.kindOfObject = "replica group"; - ex1.id = _replicaGroupId; - throw ex1; + throw new NotRegisteredException("replica group", _replicaGroupId); } catch (AdapterAlreadyActiveException) { @@ -1591,9 +1584,7 @@ private void updateLocatorRegistry(LocatorInfo? locatorInfo, ObjectPrx? proxy) _instance.initializationData().logger!.trace(_instance.traceLevels().locationCat, s.ToString()); } - ObjectAdapterIdInUseException ex1 = new ObjectAdapterIdInUseException(); - ex1.id = _id; - throw; + throw new ObjectAdapterIdInUseException(_id); } catch (ObjectAdapterDeactivatedException) { diff --git a/csharp/src/Ice/OldLocalExceptions.cs b/csharp/src/Ice/OldLocalExceptions.cs deleted file mode 100644 index 20763345d9a..00000000000 --- a/csharp/src/Ice/OldLocalExceptions.cs +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) ZeroC, Inc. - -namespace Ice; - -/// -/// An attempt was made to register something more than once with the Ice run time. -/// This exception is raised if an -/// attempt is made to register a servant, servant locator, facet, value factory, plug-in, object adapter, object, or -/// user exception factory more than once for the same ID. -/// -public class AlreadyRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public AlreadyRegisteredException() - { - _initDM(); - } - - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } - - public AlreadyRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } - - public override string ice_id() - { - return "::Ice::AlreadyRegisteredException"; - } -} - -/// -/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. -/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, -/// object adapter, object, or user exception factory that is not currently registered. It's also raised if the Ice -/// locator can't find an object or object adapter when resolving an indirect proxy or when an object adapter is -/// activated. -/// -public class NotRegisteredException : LocalException -{ - public string kindOfObject; - public string id; - - private void _initDM() - { - this.kindOfObject = ""; - this.id = ""; - } - - public NotRegisteredException() - { - _initDM(); - } - - public NotRegisteredException(System.Exception ex) : base(ex) - { - _initDM(); - } - - private void _initDM(string kindOfObject, string id) - { - this.kindOfObject = kindOfObject; - this.id = id; - } - - public NotRegisteredException(string kindOfObject, string id) - { - _initDM(kindOfObject, id); - } - - public override string ice_id() - { - return "::Ice::NotRegisteredException"; - } -} - -/// -/// This exception is raised if an ObjectAdapter cannot be activated. -/// This happens if the Locator -/// detects another active ObjectAdapter with the same adapter id. -/// -public class ObjectAdapterIdInUseException : LocalException -{ - public string id; - - private void _initDM() - { - this.id = ""; - } - - public ObjectAdapterIdInUseException() - { - _initDM(); - } - - public override string ice_id() - { - return "::Ice::ObjectAdapterIdInUseException"; - } -} - -/// -/// This exception is raised by an operation call if the application closes the connection locally using -/// Connection.close. -/// -public class ConnectionManuallyClosedException : LocalException -{ - public bool graceful; - - private void _initDM(bool graceful) - { - this.graceful = graceful; - } - - public ConnectionManuallyClosedException(bool graceful) - { - _initDM(graceful); - } - - public override string ice_id() - { - return "::Ice::ConnectionManuallyClosedException"; - } -} diff --git a/csharp/src/Ice/PluginManagerI.cs b/csharp/src/Ice/PluginManagerI.cs index df811f331bd..567670c9ee8 100644 --- a/csharp/src/Ice/PluginManagerI.cs +++ b/csharp/src/Ice/PluginManagerI.cs @@ -122,10 +122,7 @@ public Plugin getPlugin(string name) return p; } - NotRegisteredException ex = new NotRegisteredException(); - ex.id = name; - ex.kindOfObject = _kindOfObject; - throw ex; + throw new NotRegisteredException(_kindOfObject, name); } } @@ -140,10 +137,7 @@ public void addPlugin(string name, Plugin plugin) if (findPlugin(name) is not null) { - AlreadyRegisteredException ex = new AlreadyRegisteredException(); - ex.id = name; - ex.kindOfObject = _kindOfObject; - throw ex; + throw new AlreadyRegisteredException(_kindOfObject, name); } _plugins.Add(new PluginInfo(name, plugin)); diff --git a/csharp/test/Ice/ami/AllTests.cs b/csharp/test/Ice/ami/AllTests.cs index ee771b4d2cc..3502383fd07 100644 --- a/csharp/test/Ice/ami/AllTests.cs +++ b/csharp/test/Ice/ami/AllTests.cs @@ -442,9 +442,9 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll await t; test(false); } - catch (ConnectionManuallyClosedException ex) + catch (ConnectionClosedException ex) { - test(ex.graceful); + test(ex.closedByApplication); } test(p.opBatchCount() == 0); test(!tcs.Task.IsCompleted); @@ -770,7 +770,7 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll // // Local case: start an operation and then close the connection gracefully on the client side // without waiting for the pending invocation to complete. There will be no retry and we expect the - // invocation to fail with ConnectionManuallyClosedException. + // invocation to fail with ConnectionClosedException. // p = (Test.TestIntfPrx)p.ice_connectionId("CloseGracefully"); // Start with a new connection. Connection con = p.ice_getConnection(); @@ -783,9 +783,9 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll await t; test(false); } - catch (ConnectionManuallyClosedException ex) + catch (ConnectionClosedException ex) { - test(ex.graceful); + test(ex.closedByApplication); } p.finishDispatch(); @@ -808,7 +808,7 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll { // // Local case: start an operation and then close the connection forcefully on the client side. - // There will be no retry and we expect the invocation to fail with ConnectionManuallyClosedException. + // There will be no retry and we expect the invocation to fail with ConnectionClosedException. // p.ice_ping(); Connection con = p.ice_getConnection(); @@ -822,9 +822,9 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll await t; test(false); } - catch (ConnectionManuallyClosedException ex) + catch (ConnectionClosedException ex) { - test(!ex.graceful); + test(ex.closedByApplication); } p.finishDispatch(); diff --git a/csharp/test/Ice/timeout/AllTests.cs b/csharp/test/Ice/timeout/AllTests.cs index a88a6a7a846..8f01b55af9c 100644 --- a/csharp/test/Ice/timeout/AllTests.cs +++ b/csharp/test/Ice/timeout/AllTests.cs @@ -163,10 +163,10 @@ public static async Task allTestsWithController(global::Test.TestHelper helper, connection.getInfo(); Thread.Sleep(10); } - catch (ConnectionManuallyClosedException ex) + catch (ConnectionClosedException ex) { // Expected. - test(ex.graceful); + test(ex.closedByApplication); break; } } From 8c1211192b6bc6365efadc5f7e5ee8cd6a4d943a Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 18:01:53 -0400 Subject: [PATCH 12/21] More cleanup --- csharp/src/Ice/Internal/Ex.cs | 12 +++--------- csharp/src/Ice/LocalException.cs | 2 +- csharp/src/Ice/LocalExceptions.cs | 2 +- csharp/src/Ice/PluginManagerI.cs | 2 +- csharp/src/Ice/SSL/RFC2253.cs | 9 --------- csharp/src/Ice/SSL/TrustManager.cs | 8 ++++---- csharp/src/Ice/UserException.cs | 2 +- csharp/src/Ice/UtilInternal/Options.cs | 13 +++---------- csharp/src/IceBoxNet/ServiceManagerI.cs | 2 +- csharp/test/IceUtil/inputUtil/Client.cs | 4 ++-- 10 files changed, 17 insertions(+), 39 deletions(-) diff --git a/csharp/src/Ice/Internal/Ex.cs b/csharp/src/Ice/Internal/Ex.cs index b1000773044..fab1927d19a 100644 --- a/csharp/src/Ice/Internal/Ex.cs +++ b/csharp/src/Ice/Internal/Ex.cs @@ -39,15 +39,9 @@ public static void throwMemoryLimitException(int requested, int maximum) public class RetryException : System.Exception { - public RetryException(Ice.LocalException ex) - { - _ex = ex; - } + private readonly Ice.LocalException _ex; - public Ice.LocalException get() - { - return _ex; - } + public RetryException(Ice.LocalException ex) => _ex = ex; - private Ice.LocalException _ex; + public Ice.LocalException get() => _ex; } diff --git a/csharp/src/Ice/LocalException.cs b/csharp/src/Ice/LocalException.cs index 3d0d222591d..51ca9de20c2 100644 --- a/csharp/src/Ice/LocalException.cs +++ b/csharp/src/Ice/LocalException.cs @@ -7,7 +7,7 @@ namespace Ice; /// /// Base class for Ice run-time exceptions. /// -public class LocalException : Exception +public class LocalException : Ice.Exception { /// /// Constructs a LocalException. diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index ebddfd5d300..b75f36ffc95 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -510,7 +510,7 @@ public ConnectionLostException(System.Exception? innerException = null) /// This exception is raised if an ObjectAdapter cannot be activated. /// This happens if the Locator detects another active ObjectAdapter with the same adapter ID. /// -public class ObjectAdapterIdInUseException : LocalException +public sealed class ObjectAdapterIdInUseException : LocalException { public ObjectAdapterIdInUseException(string adapterId) : base($"An object adapter with adapter ID '{adapterId}' is already active.") diff --git a/csharp/src/Ice/PluginManagerI.cs b/csharp/src/Ice/PluginManagerI.cs index 567670c9ee8..6bb3c9e1b80 100644 --- a/csharp/src/Ice/PluginManagerI.cs +++ b/csharp/src/Ice/PluginManagerI.cs @@ -345,7 +345,7 @@ private void loadPlugin(string name, string pluginSpec, ref string[] cmdArgs) { args = Ice.UtilInternal.Options.split(pluginSpec); } - catch (Ice.UtilInternal.Options.BadQuote ex) + catch (ParseException ex) { throw new PluginInitializationException($"Invalid arguments for plug-in '{name}'.", ex); } diff --git a/csharp/src/Ice/SSL/RFC2253.cs b/csharp/src/Ice/SSL/RFC2253.cs index 5e905139e75..9dcc9823317 100644 --- a/csharp/src/Ice/SSL/RFC2253.cs +++ b/csharp/src/Ice/SSL/RFC2253.cs @@ -12,15 +12,6 @@ namespace Ice.SSL; internal class RFC2253 { - public class ParseException : System.Exception - { - public ParseException(string reason) => this.reason = reason; - - internal string ice_id() => "::RFC2253::ParseException"; - - internal readonly string reason; - } - internal struct RDNPair { internal string key; diff --git a/csharp/src/Ice/SSL/TrustManager.cs b/csharp/src/Ice/SSL/TrustManager.cs index 060d75bac2f..7abcee23848 100644 --- a/csharp/src/Ice/SSL/TrustManager.cs +++ b/csharp/src/Ice/SSL/TrustManager.cs @@ -43,9 +43,9 @@ internal TrustManager(Ice.Communicator communicator) } } } - catch (RFC2253.ParseException ex) + catch (ParseException ex) { - throw new Ice.PluginInitializationException($"IceSSL: invalid property {key}:\n {ex.reason}"); + throw new PluginInitializationException($"IceSSL: invalid property {key}", ex); } } @@ -176,10 +176,10 @@ internal bool verify(ConnectionInfo info, string description) } } } - catch (RFC2253.ParseException e) + catch (ParseException e) { _communicator.getLogger().warning( - $"IceSSL: unable to parse certificate DN `{subjectName}'\nreason: {e.reason}"); + $"IceSSL: unable to parse certificate DN `{subjectName}'\nreason: {e.Message}"); } // At this point we accept the connection if there are no explicit accept rules. diff --git a/csharp/src/Ice/UserException.cs b/csharp/src/Ice/UserException.cs index a445640ea51..4b78b16f607 100644 --- a/csharp/src/Ice/UserException.cs +++ b/csharp/src/Ice/UserException.cs @@ -7,7 +7,7 @@ namespace Ice; /// /// Base class for exceptions defined in Slice. /// -public abstract class UserException : Exception +public abstract class UserException : Ice.Exception { public virtual void iceWrite(OutputStream ostr) { diff --git a/csharp/src/Ice/UtilInternal/Options.cs b/csharp/src/Ice/UtilInternal/Options.cs index 305708ece04..cdb9da202d3 100644 --- a/csharp/src/Ice/UtilInternal/Options.cs +++ b/csharp/src/Ice/UtilInternal/Options.cs @@ -7,13 +7,6 @@ namespace Ice.UtilInternal; public sealed class Options { - public sealed class BadQuote : System.Exception - { - public BadQuote(string message) : base(message) - { - } - } - private enum State { Normal, DoubleQuote, SingleQuote, ANSIQuote }; static public string[] @@ -374,15 +367,15 @@ static public string[] } case State.SingleQuote: { - throw new BadQuote("missing closing single quote"); + throw new ParseException("missing closing single quote"); } case State.DoubleQuote: { - throw new BadQuote("missing closing double quote"); + throw new ParseException("missing closing double quote"); } case State.ANSIQuote: { - throw new BadQuote("unterminated $' quote"); + throw new ParseException("unterminated $' quote"); } default: { diff --git a/csharp/src/IceBoxNet/ServiceManagerI.cs b/csharp/src/IceBoxNet/ServiceManagerI.cs index 1263f9c6c8f..96c62cc6f8c 100644 --- a/csharp/src/IceBoxNet/ServiceManagerI.cs +++ b/csharp/src/IceBoxNet/ServiceManagerI.cs @@ -861,7 +861,7 @@ public StartServiceInfo(string service, string value, string[] serverArgs) { args = Ice.UtilInternal.Options.split(value); } - catch (Ice.UtilInternal.Options.BadQuote ex) + catch (Ice.ParseException ex) { FailureException e = new FailureException(); e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.Message; diff --git a/csharp/test/IceUtil/inputUtil/Client.cs b/csharp/test/IceUtil/inputUtil/Client.cs index 68bb1b35411..2457961712a 100644 --- a/csharp/test/IceUtil/inputUtil/Client.cs +++ b/csharp/test/IceUtil/inputUtil/Client.cs @@ -62,7 +62,7 @@ public override void run(string[] argvs) args = Ice.UtilInternal.Options.split("-Dir=$'C:\\\\\\cM\\x66\\146i'"); // -Dir=$'C:\\\cM\x66\146i' test(args.Length == 1 && args[0] == "-Dir=C:\\\x000Dffi"); } - catch (Ice.UtilInternal.Options.BadQuote) + catch (Ice.ParseException) { test(false); } @@ -81,7 +81,7 @@ public override void run(string[] argvs) Ice.UtilInternal.Options.split(badQuoteCommands[i]); test(false); } - catch (Ice.UtilInternal.Options.BadQuote) + catch (Ice.ParseException) { } } From 004157d91dd81c2c361f18f2c4d60cea10623845 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 18:19:33 -0400 Subject: [PATCH 13/21] Fix IceBox local exception --- csharp/src/IceBox/Service.cs | 44 ++++---------------- csharp/src/IceBoxNet/ServiceManagerI.cs | 55 +++++++------------------ 2 files changed, 25 insertions(+), 74 deletions(-) diff --git a/csharp/src/IceBox/Service.cs b/csharp/src/IceBox/Service.cs index bb0ecb5098e..f4e43a6df8d 100644 --- a/csharp/src/IceBox/Service.cs +++ b/csharp/src/IceBox/Service.cs @@ -1,50 +1,24 @@ // Copyright (c) ZeroC, Inc. +#nullable enable + namespace IceBox; /// /// This exception is a general failure notification. -/// It is thrown for errors such as a service encountering an error -/// during initialization, or the service manager being unable to load a service executable. +/// It is thrown for errors such as a service encountering an error during initialization, or the service manager +/// being unable to load a service executable. /// -public class FailureException : Ice.LocalException +public sealed class FailureException : Ice.LocalException { - public string reason; - - private void _initDM() - { - this.reason = ""; - } - - public FailureException() - { - _initDM(); - } - - public FailureException(System.Exception ex) : base(ex) - { - _initDM(); - } + public string reason => Message; - private void _initDM(string reason) + public FailureException(string? message, System.Exception? innerException = null) + : base(message, innerException) { - this.reason = reason; } - public FailureException(string reason) - { - _initDM(reason); - } - - public FailureException(string reason, System.Exception ex) : base(ex) - { - _initDM(reason); - } - - public override string ice_id() - { - return "::IceBox::FailureException"; - } + public override string ice_id() => "::IceBox::FailureException"; } public interface Service diff --git a/csharp/src/IceBoxNet/ServiceManagerI.cs b/csharp/src/IceBoxNet/ServiceManagerI.cs index 96c62cc6f8c..ce2c8e1bf4c 100644 --- a/csharp/src/IceBoxNet/ServiceManagerI.cs +++ b/csharp/src/IceBoxNet/ServiceManagerI.cs @@ -269,7 +269,7 @@ public int run() if (services.Count == 0) { - throw new FailureException("ServiceManager: configuration must include at least one IceBox service"); + throw new FailureException("ServiceManager: configuration must include at least one IceBox service."); } string[] loadOrder = properties.getIcePropertyAsList("IceBox.LoadOrder"); @@ -279,12 +279,9 @@ public int run() if (loadOrder[i].Length > 0) { string key = prefix + loadOrder[i]; - string value; - if (!services.TryGetValue(key, out value)) + if (!services.TryGetValue(key, out string value)) { - FailureException ex = new FailureException(); - ex.reason = "ServiceManager: no service definition for `" + loadOrder[i] + "'"; - throw ex; + throw new FailureException($"ServiceManager: no service definition for '{loadOrder[i]}'."); } servicesInfo.Add(new StartServiceInfo(loadOrder[i], value, _argv)); services.Remove(key); @@ -452,9 +449,7 @@ private void startService(string service, string entryPoint, string[] args) } if (sepPos == -1) { - FailureException e = new FailureException(); - e.reason = err + "invalid entry point format"; - throw e; + throw new FailureException($"{err}invalid entry point format."); } System.Reflection.Assembly serviceAssembly = null; @@ -487,9 +482,7 @@ private void startService(string service, string entryPoint, string[] args) } catch (Exception ex) { - FailureException e = new FailureException(ex); - e.reason = err + "unable to load assembly: " + assemblyName; - throw e; + throw new FailureException($"{err}unable to load assembly: {assemblyName}", ex); } // @@ -502,9 +495,7 @@ private void startService(string service, string entryPoint, string[] args) } catch (Exception ex) { - FailureException e = new FailureException(ex); - e.reason = err + "GetType failed for '" + className + "'"; - throw e; + throw new FailureException($"{err}GetType failed for '{className}'.", ex); } ServiceInfo info = new ServiceInfo(); @@ -611,9 +602,9 @@ private void startService(string service, string entryPoint, string[] args) } catch (MethodAccessException ex) { - FailureException e = new FailureException(ex); - e.reason = err + "unable to access service constructor " + className + "(Ice.Communicator)"; - throw e; + throw new FailureException( + $"{err}unable to access service constructor {className}(Ice.Communicator).", + ex); } } else @@ -626,16 +617,12 @@ private void startService(string service, string entryPoint, string[] args) info.service = (Service)Ice.Internal.AssemblyUtil.createInstance(c); if (info.service == null) { - FailureException e = new FailureException(); - e.reason = err + "no default constructor for '" + className + "'"; - throw e; + throw new FailureException($"{err}no default constructor for '{className}'."); } } catch (UnauthorizedAccessException ex) { - FailureException e = new FailureException(ex); - e.reason = err + "unauthorized access to default service constructor for " + className; - throw e; + throw new FailureException($"{err}unauthorized access to default service constructor for '{className}'.", ex); } } } @@ -645,9 +632,7 @@ private void startService(string service, string entryPoint, string[] args) } catch (InvalidCastException ex) { - FailureException e = new FailureException(ex); - e.reason = err + "service does not implement IceBox.Service"; - throw e; + throw new FailureException($"{err}service does not implement IceBox.Service.", ex); } catch (System.Reflection.TargetInvocationException ex) { @@ -657,16 +642,12 @@ private void startService(string service, string entryPoint, string[] args) } else { - FailureException e = new FailureException(ex.InnerException); - e.reason = err + "exception in service constructor for " + className; - throw e; + throw new FailureException($"{err}exception in service constructor for '{className}'.", ex.InnerException); } } catch (Exception ex) { - FailureException e = new FailureException(ex); - e.reason = err + "exception in service constructor " + className; - throw e; + throw new FailureException($"{err}exception in service constructor for '{className}'.", ex); } try @@ -679,9 +660,7 @@ private void startService(string service, string entryPoint, string[] args) } catch (Exception ex) { - FailureException e = new FailureException(ex); - e.reason = "exception while starting service " + service; - throw e; + throw new FailureException($"{err}exception while starting service '{service}'.", ex); } info.status = ServiceStatus.Started; @@ -863,9 +842,7 @@ public StartServiceInfo(string service, string value, string[] serverArgs) } catch (Ice.ParseException ex) { - FailureException e = new FailureException(); - e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.Message; - throw e; + throw new FailureException($"ServiceManager: invalid arguments for service '{name}'.", ex); } Debug.Assert(args.Length > 0); From f79da3c25150f49da5aca85c9d2ea3ccb473b348 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 18:49:24 -0400 Subject: [PATCH 14/21] More cleanup --- csharp/src/Ice/Internal/OutgoingAsync.cs | 57 +-- csharp/src/Ice/LocalExceptions.cs | 430 ++++++++++++----------- 2 files changed, 235 insertions(+), 252 deletions(-) diff --git a/csharp/src/Ice/Internal/OutgoingAsync.cs b/csharp/src/Ice/Internal/OutgoingAsync.cs index f2b62b8b967..30f0f9e3189 100644 --- a/csharp/src/Ice/Internal/OutgoingAsync.cs +++ b/csharp/src/Ice/Internal/OutgoingAsync.cs @@ -760,7 +760,6 @@ public override bool response() // For compatibility with the old FacetPath. // string[] facetPath = is_.readStringSeq(); - ; string facet; if (facetPath.Length > 0) { @@ -776,39 +775,19 @@ public override bool response() } string operation = is_.readString(); - - Ice.RequestFailedException ex = null; switch (replyStatus) { case ReplyStatus.ObjectNotExist: - { - ex = new Ice.ObjectNotExistException(); - break; - } + throw new ObjectNotExistException(ident, facet, operation); case ReplyStatus.FacetNotExist: - { - ex = new Ice.FacetNotExistException(); - break; - } + throw new FacetNotExistException(ident, facet, operation); case ReplyStatus.OperationNotExist: - { - ex = new Ice.OperationNotExistException(); - break; - } - - default: - { - Debug.Assert(false); - break; - } + throw new OperationNotExistException(ident, facet, operation); } - - ex.id = ident; - ex.facet = facet; - ex.operation = operation; - throw ex; + Debug.Assert(false); + break; } case ReplyStatus.UnknownException: @@ -816,35 +795,19 @@ public override bool response() case ReplyStatus.UnknownUserException: { string message = is_.readString(); - - Ice.UnknownException ex = null; switch (replyStatus) { case ReplyStatus.UnknownException: - { - ex = new UnknownException(message); - break; - } + throw new UnknownException(message); case ReplyStatus.UnknownLocalException: - { - ex = new UnknownLocalException(message); - break; - } + throw new UnknownLocalException(message); case ReplyStatus.UnknownUserException: - { - ex = new UnknownUserException(message); - break; - } - - default: - { - Debug.Assert(false); - break; - } + throw new UnknownUserException(message); } - throw ex; + Debug.Assert(false); + break; } default: diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index b75f36ffc95..df994f05173 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -4,10 +4,12 @@ namespace Ice; -// This file contains all the exception classes derived from LocalException. +// This file contains all the exception classes derived from LocalException defined in the Ice assembly. -// The 3 NotExist exceptions and the 3 Unknown exceptions are special local exceptions that can be marshaled in an Ice -// reply message. Other local exceptions can't be marshaled. +// +// The 6 (7 with the RequestFailedException base class) special local exceptions that can be marshaled in an Ice reply +// message. Other local exceptions can't be marshaled. +// /// /// The base exception for the 3 NotExist exceptions. @@ -28,6 +30,11 @@ protected RequestFailedException(Identity id, string facet, string operation) this.facet = facet; this.operation = operation; } + + protected RequestFailedException() + : this(new Identity(), "", "") + { + } } /// @@ -36,7 +43,6 @@ protected RequestFailedException(Identity id, string facet, string operation) public sealed class ObjectNotExistException : RequestFailedException { public ObjectNotExistException() - : base(new Identity(), "", "") { } @@ -54,7 +60,6 @@ public ObjectNotExistException(Identity id, string facet, string operation) public sealed class FacetNotExistException : RequestFailedException { public FacetNotExistException() - : base(new Identity(), "", "") { } @@ -73,7 +78,6 @@ public FacetNotExistException(Identity id, string facet, string operation) public sealed class OperationNotExistException : RequestFailedException { public OperationNotExistException() - : base(new Identity(), "", "") { } @@ -128,435 +132,451 @@ public UnknownUserException(string message) public override string ice_id() => "::Ice::UnknownUserException"; } +// +// Protocol exceptions +// + /// -/// This exception is raised if the Communicator has been destroyed. +/// The base class for Ice protocol exceptions. /// -public sealed class CommunicatorDestroyedException : LocalException +public class ProtocolException : LocalException { - public CommunicatorDestroyedException() - : base("Communicator destroyed.") + public ProtocolException(string? message = null, System.Exception? innerException = null) + : base(message, innerException) { } - public override string ice_id() => "::Ice::CommunicatorDestroyedException"; + public override string ice_id() => "::Ice::ProtocolException"; } /// -/// This exception indicates that a connection was closed gracefully. +/// This exception indicates that the connection has been gracefully closed by the server. +/// The operation call that caused this exception has not been executed by the server. In most cases you will not get +/// this exception because the client will automatically retry the operation call in case the server shut down the +/// connection. However, if upon retry the server shuts down the connection again, and the retry limit has been reached, +/// then this exception is propagated to the application code. /// -public sealed class ConnectionClosedException : LocalException +public sealed class CloseConnectionException : ProtocolException { - public bool closedByApplication { get; } - - public ConnectionClosedException(string message, bool closedByApplication) - : base(message, innerException: null) => - this.closedByApplication = closedByApplication; + public CloseConnectionException() + : base(message: "Connection closed by the peer.", innerException: null) + { + } - public override string ice_id() => "::Ice::ConnectionClosedException"; + public override string ice_id() => "::Ice::CloseConnectionException"; } /// -/// This exception indicates that a connection was aborted by the idle check. +/// A datagram exceeds the configured size. +/// This exception is raised if a datagram exceeds the configured send or receive buffer size, or exceeds the maximum +/// payload size of a UDP packet (65507 bytes). /// -public sealed class ConnectionIdleException : LocalException +public sealed class DatagramLimitException : ProtocolException { - public ConnectionIdleException(string message) - : base(message, innerException: null) + public DatagramLimitException() + : base(message: "Datagram limit exceeded.", innerException: null) { } - public override string ice_id() => "::Ice::ConnectionIdleException"; + public override string ice_id() => "::Ice::DatagramLimitException"; } /// -/// This exception is raised if an unsupported feature is used. +/// This exception reports an error during marshaling or unmarshaling. /// -public sealed class FeatureNotSupportedException : LocalException +public sealed class MarshalException : ProtocolException { - public FeatureNotSupportedException(string message) - : base(message) + public MarshalException(string message, System.Exception? innerException = null) + : base(message, innerException) { } - public override string ice_id() => "::Ice::FeatureNotSupportedException"; + public override string ice_id() => "::Ice::MarshalException"; } -/// -/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. -/// -public sealed class FixedProxyException : LocalException +// +// Timeout exceptions +// + +/// This exception indicates a timeout condition. +public class TimeoutException : LocalException { - public FixedProxyException() - : base("Cannot change the connection properties of a fixed proxy.") + public TimeoutException(string? message = null, System.Exception? innerException = null) + : base(message ?? "Operation timed out.", innerException) { } - public override string ice_id() => "::Ice::FixedProxyException"; + public override string ice_id() => "::Ice::TimeoutException"; } -/// -/// This exception is raised when a failure occurs during initialization. -/// -public sealed class InitializationException : LocalException +/// This exception indicates a connection closure timeout condition. +public sealed class CloseTimeoutException : TimeoutException { - public InitializationException(string message, System.Exception? innerException = null) - : base(message, innerException) + public CloseTimeoutException() + : base("Close timed out.") { } - public override string ice_id() => "::Ice::InitializationException"; + public override string ice_id() => "::Ice::CloseTimeoutException"; } /// -/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. +/// This exception indicates a connection establishment timeout condition. /// -public sealed class InvocationCanceledException : LocalException +public sealed class ConnectTimeoutException : TimeoutException { - public InvocationCanceledException() - : base("Invocation canceled.") + public ConnectTimeoutException() + : base("Connect timed out.") { } - public override string ice_id() => "::Ice::InvocationCanceledException"; + public override string ice_id() => "::Ice::ConnectTimeoutException"; } /// -/// This exception is raised if no suitable endpoint is available. +/// This exception indicates that an invocation failed because it timed out. /// -public sealed class NoEndpointException : LocalException +public sealed class InvocationTimeoutException : TimeoutException { - public NoEndpointException(string message) - : base(message) - { - } - - public NoEndpointException(ObjectPrx proxy) - : base($"No suitable endpoint available for proxy '{proxy}'.") + public InvocationTimeoutException() + : base("Invocation timed out.") { } - public override string ice_id() => "::Ice::NoEndpointException"; + public override string ice_id() => "::Ice::InvocationTimeoutException"; } +// +// Syscall exceptions +// + /// -/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. +/// This exception is raised if a system error occurred in the server or client process. /// -public sealed class ObjectAdapterDeactivatedException : LocalException +public class SyscallException : LocalException { - public ObjectAdapterDeactivatedException(string name) - : base($"Object adapter '{name}' is deactivated.") + public SyscallException(string? message = null, System.Exception? innerException = null) + : base(message, innerException) { } - public override string ice_id() => "::Ice::ObjectAdapterDeactivatedException"; + public SyscallException(System.Exception innerException) + : base(innerException) + { + } + + public override string ice_id() => "::Ice::SyscallException"; } /// -/// Reports a failure that occurred while parsing a string. +/// This exception indicates a connection failure. /// -public sealed class ParseException : LocalException +public class ConnectFailedException : SocketException { - public ParseException(string message, System.Exception? innerException = null) - : base(message, innerException) + public ConnectFailedException(System.Exception? innerException = null) + : base(innerException) { } - public override string ice_id() => "::Ice::ParseException"; + public override string ice_id() => "::Ice::ConnectFailedException"; } /// -/// This exception indicates that a failure occurred while initializing a plug-in. +/// This exception indicates a lost connection. /// -public sealed class PluginInitializationException : LocalException +public sealed class ConnectionLostException : SocketException { - public PluginInitializationException(string message, System.Exception? innerException = null) - : base(message, innerException) + public ConnectionLostException(System.Exception? innerException = null) + : base(innerException) { } - public override string ice_id() => "::Ice::PluginInitializationException"; + public override string ice_id() => "::Ice::ConnectionLostException"; } /// -/// This exception indicates a failure in a security subsystem. +/// This exception indicates a connection failure for which the server host actively refuses a connection. /// -public sealed class SecurityException : LocalException +public sealed class ConnectionRefusedException : ConnectFailedException { - public SecurityException(string message, System.Exception? innerException = null) - : base(message, innerException) + public ConnectionRefusedException(System.Exception? innerException = null) + : base(innerException) { } - public override string ice_id() => "::Ice::SecurityException"; + public override string ice_id() => "::Ice::ConnectionRefusedException"; } /// -/// The operation can only be invoked with a two-way request. -/// This exception is raised if an attempt is made to invoke an operation with ice_oneway, ice_batchOneway, -/// ice_datagram, or ice_batchDatagram and the operation has a return value, out-parameters, or an exception -/// specification. +/// This exception indicates a DNS problem. /// -public sealed class TwowayOnlyException : LocalException +public sealed class DNSException : SyscallException { - public TwowayOnlyException(string operation) - : base($"Cannot invoke operation '{operation}' with a oneway, batchOneway, datagram, or batchDatagram proxy.") + public DNSException(string host, System.Exception? innerException = null) + : base($"Cannot resolve host '{host}'", innerException) { } - public override string ice_id() => "::Ice::TwowayOnlyException"; + public override string ice_id() => "::Ice::DNSException"; } -/// -/// The base class for Ice protocol exceptions. -/// -public class ProtocolException : LocalException +/// This exception indicates a file error. +public sealed class FileException : SyscallException { - public ProtocolException(string? message = null, System.Exception? innerException = null) + public FileException(string message, System.Exception innerException) : base(message, innerException) { } - public override string ice_id() => "::Ice::ProtocolException"; + public override string ice_id() => "::Ice::FileException"; } /// -/// This exception indicates that the connection has been gracefully closed by the server. -/// The operation call that caused this exception has not been executed by the server. In most cases you will not get -/// this exception because the client will automatically retry the operation call in case the server shut down the -/// connection. However, if upon retry the server shuts down the connection again, and the retry limit has been reached, -/// then this exception is propagated to the application code. +/// This exception indicates a socket error. /// -public sealed class CloseConnectionException : ProtocolException +public class SocketException : SyscallException { - public CloseConnectionException() - : base(message: "Connection closed by the peer.", innerException: null) + public SocketException(System.Exception? innerException = null) + : base(message: null, innerException) { } - public override string ice_id() => "::Ice::CloseConnectionException"; + public override string ice_id() => "::Ice::SocketException"; } +// +// Other leaf local exceptions in alphabetical order. +// + /// -/// A datagram exceeds the configured size. -/// This exception is raised if a datagram exceeds the configured send or receive buffer size, or exceeds the maximum -/// payload size of a UDP packet (65507 bytes). +/// An attempt was made to register something more than once with the Ice run time. +/// This exception is raised if an attempt is made to register a servant, servant locator, facet, value factory, +/// plug-in, object adapter (etc.) more than once for the same ID. /// -public sealed class DatagramLimitException : ProtocolException +public sealed class AlreadyRegisteredException : LocalException { - public DatagramLimitException() - : base(message: "Datagram limit exceeded.", innerException: null) + public string kindOfObject { get; } + public string id { get; } + + public AlreadyRegisteredException(string kindOfObject, string id) + : base($"Another {kindOfObject} is already registered with ID '{id}'.") { + this.kindOfObject = kindOfObject; + this.id = id; } - public override string ice_id() => "::Ice::DatagramLimitException"; + public override string ice_id() => "::Ice::AlreadyRegisteredException"; } /// -/// This exception reports an error during marshaling or unmarshaling. +/// This exception is raised if the Communicator has been destroyed. /// -public sealed class MarshalException : ProtocolException +public sealed class CommunicatorDestroyedException : LocalException { - public MarshalException(string message, System.Exception? innerException = null) - : base(message, innerException) + public CommunicatorDestroyedException() + : base("Communicator destroyed.") { } - public override string ice_id() => "::Ice::MarshalException"; + public override string ice_id() => "::Ice::CommunicatorDestroyedException"; } -/// This exception indicates a timeout condition. -public class TimeoutException : LocalException +/// +/// This exception indicates that a connection was closed. +/// +public sealed class ConnectionClosedException : LocalException { - public TimeoutException(string? message = null, System.Exception? innerException = null) - : base(message ?? "Operation timed out.", innerException) - { - } + public bool closedByApplication { get; } - public override string ice_id() => "::Ice::TimeoutException"; + public ConnectionClosedException(string message, bool closedByApplication) + : base(message, innerException: null) => + this.closedByApplication = closedByApplication; + + public override string ice_id() => "::Ice::ConnectionClosedException"; } /// -/// This exception indicates a connection establishment timeout condition. +/// This exception indicates that a connection was aborted by the idle check. /// -public sealed class ConnectTimeoutException : TimeoutException +public sealed class ConnectionIdleException : LocalException { - public ConnectTimeoutException() - : base("Connect timed out.") + public ConnectionIdleException(string message) + : base(message, innerException: null) { } - public override string ice_id() => "::Ice::ConnectTimeoutException"; + public override string ice_id() => "::Ice::ConnectionIdleException"; } -/// This exception indicates a connection closure timeout condition. -public sealed class CloseTimeoutException : TimeoutException +/// +/// This exception is raised if an unsupported feature is used. +/// +public sealed class FeatureNotSupportedException : LocalException { - public CloseTimeoutException() - : base("Close timed out.") + public FeatureNotSupportedException(string message) + : base(message) { } - public override string ice_id() => "::Ice::CloseTimeoutException"; + public override string ice_id() => "::Ice::FeatureNotSupportedException"; } /// -/// This exception indicates that an invocation failed because it timed out. +/// This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. /// -public sealed class InvocationTimeoutException : TimeoutException +public sealed class FixedProxyException : LocalException { - public InvocationTimeoutException() - : base("Invocation timed out.") + public FixedProxyException() + : base("Cannot change the connection properties of a fixed proxy.") { } - public override string ice_id() => "::Ice::InvocationTimeoutException"; + public override string ice_id() => "::Ice::FixedProxyException"; } /// -/// This exception is raised if a system error occurred in the server or client process. +/// This exception is raised when a failure occurs during initialization. /// -public class SyscallException : LocalException +public sealed class InitializationException : LocalException { - public SyscallException(string? message = null, System.Exception? innerException = null) + public InitializationException(string message, System.Exception? innerException = null) : base(message, innerException) { } - public SyscallException(System.Exception innerException) - : base(innerException) - { - } - - public override string ice_id() => "::Ice::SyscallException"; + public override string ice_id() => "::Ice::InitializationException"; } /// -/// This exception indicates a DNS problem. +/// This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. /// -public sealed class DNSException : SyscallException +public sealed class InvocationCanceledException : LocalException { - public DNSException(string host, System.Exception? innerException = null) - : base($"Cannot resolve host '{host}'", innerException) + public InvocationCanceledException() + : base("Invocation canceled.") { } - public override string ice_id() => "::Ice::DNSException"; + public override string ice_id() => "::Ice::InvocationCanceledException"; } /// -/// This exception indicates socket errors. +/// This exception is raised if no suitable endpoint is available. /// -public class SocketException : SyscallException +public sealed class NoEndpointException : LocalException { - public SocketException(System.Exception? innerException = null) - : base(message: null, innerException) + public NoEndpointException(string message) + : base(message) { } - public override string ice_id() => "::Ice::SocketException"; + public NoEndpointException(ObjectPrx proxy) + : base($"No suitable endpoint available for proxy '{proxy}'.") + { + } + + public override string ice_id() => "::Ice::NoEndpointException"; } -/// This exception indicates file errors. -public sealed class FileException : SyscallException +/// +/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. +/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, +/// object adapter (etc.) that is not currently registered. It's also raised if the Ice locator can't find an object or +/// object adapter when resolving an indirect proxy or when an object adapter is activated. +/// +public sealed class NotRegisteredException : LocalException { - public FileException(string message, System.Exception innerException) - : base(message, innerException) + public string kindOfObject { get; } + public string id { get; } + + public NotRegisteredException(string kindOfObject, string id) + : base($"No {kindOfObject} is registered with ID '{id}'.") { + this.kindOfObject = kindOfObject; + this.id = id; } - public override string ice_id() => "::Ice::FileException"; + public override string ice_id() => "::Ice::NotRegisteredException"; } /// -/// This exception indicates connection failures. +/// This exception is raised if an attempt is made to use a deactivated ObjectAdapter. /// -public class ConnectFailedException : SocketException +public sealed class ObjectAdapterDeactivatedException : LocalException { - public ConnectFailedException(System.Exception? innerException = null) - : base(innerException) + public ObjectAdapterDeactivatedException(string name) + : base($"Object adapter '{name}' is deactivated.") { } - public override string ice_id() => "::Ice::ConnectFailedException"; + public override string ice_id() => "::Ice::ObjectAdapterDeactivatedException"; } /// -/// This exception indicates a connection failure for which the server host actively refuses a connection. +/// This exception is raised if an ObjectAdapter cannot be activated. +/// This happens if the Locator detects another active ObjectAdapter with the same adapter ID. /// -public sealed class ConnectionRefusedException : ConnectFailedException +public sealed class ObjectAdapterIdInUseException : LocalException { - public ConnectionRefusedException(System.Exception? innerException = null) - : base(innerException) + public ObjectAdapterIdInUseException(string adapterId) + : base($"An object adapter with adapter ID '{adapterId}' is already active.") { } - public override string ice_id() => "::Ice::ConnectionRefusedException"; + public override string ice_id() => "::Ice::ObjectAdapterIdInUseException"; } /// -/// This exception indicates a lost connection. +/// Reports a failure that occurred while parsing a string. /// -public sealed class ConnectionLostException : SocketException +public sealed class ParseException : LocalException { - public ConnectionLostException(System.Exception? innerException = null) - : base(innerException) + public ParseException(string message, System.Exception? innerException = null) + : base(message, innerException) { } - public override string ice_id() => "::Ice::ConnectionLostException"; + public override string ice_id() => "::Ice::ParseException"; } /// -/// This exception is raised if an ObjectAdapter cannot be activated. -/// This happens if the Locator detects another active ObjectAdapter with the same adapter ID. +/// This exception indicates that a failure occurred while initializing a plug-in. /// -public sealed class ObjectAdapterIdInUseException : LocalException +public sealed class PluginInitializationException : LocalException { - public ObjectAdapterIdInUseException(string adapterId) - : base($"An object adapter with adapter ID '{adapterId}' is already active.") + public PluginInitializationException(string message, System.Exception? innerException = null) + : base(message, innerException) { } - public override string ice_id() => "::Ice::ObjectAdapterIdInUseException"; + public override string ice_id() => "::Ice::PluginInitializationException"; } /// -/// An attempt was made to register something more than once with the Ice run time. -/// This exception is raised if an attempt is made to register a servant, servant locator, facet, value factory, -/// plug-in, object adapter (etc.) more than once for the same ID. +/// This exception indicates a failure in a security subsystem. /// -public sealed class AlreadyRegisteredException : LocalException +public sealed class SecurityException : LocalException { - public string kindOfObject { get; } - public string id { get; } - - public AlreadyRegisteredException(string kindOfObject, string id) - : base($"Another {kindOfObject} is already registered with ID '{id}'.") + public SecurityException(string message, System.Exception? innerException = null) + : base(message, innerException) { - this.kindOfObject = kindOfObject; - this.id = id; } - public override string ice_id() => "::Ice::AlreadyRegisteredException"; + public override string ice_id() => "::Ice::SecurityException"; } /// -/// An attempt was made to find or deregister something that is not registered with the Ice run time or Ice locator. -/// This exception is raised if an attempt is made to remove a servant, servant locator, facet, value factory, plug-in, -/// object adapter (etc.) that is not currently registered. It's also raised if the Ice locator can't find an object or -/// object adapter when resolving an indirect proxy or when an object adapter is activated. +/// The operation can only be invoked with a two-way request. +/// This exception is raised if an attempt is made to invoke an operation with ice_oneway, ice_batchOneway, +/// ice_datagram, or ice_batchDatagram and the operation has a return value, out-parameters, or an exception +/// specification. /// -public sealed class NotRegisteredException : LocalException +public sealed class TwowayOnlyException : LocalException { - public string kindOfObject { get; } - public string id { get; } - - public NotRegisteredException(string kindOfObject, string id) - : base($"No {kindOfObject} is registered with ID '{id}'.") + public TwowayOnlyException(string operation) + : base($"Cannot invoke operation '{operation}' with a oneway, batchOneway, datagram, or batchDatagram proxy.") { - this.kindOfObject = kindOfObject; - this.id = id; } - public override string ice_id() => "::Ice::NotRegisteredException"; + public override string ice_id() => "::Ice::TwowayOnlyException"; } From 3b5fc1b7fb9c6d0fc3108bf927383b135893e322 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 18:59:54 -0400 Subject: [PATCH 15/21] Add ConnectionAbortedException --- CHANGELOG-3.8.md | 4 ++-- csharp/src/Ice/Connection.cs | 2 +- csharp/src/Ice/ConnectionI.cs | 5 ++++- csharp/src/Ice/Internal/RequestHandlerCache.cs | 8 +++++--- csharp/src/Ice/LocalExceptions.cs | 16 +++++++++++++++- csharp/test/Ice/ami/AllTests.cs | 4 ++-- 6 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGELOG-3.8.md b/CHANGELOG-3.8.md index 5dbde7c08c0..d53aef1522d 100644 --- a/CHANGELOG-3.8.md +++ b/CHANGELOG-3.8.md @@ -63,7 +63,7 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG |-------------------------------------|----------------------------| | BadMagicException | ProtocolException (base) | | CompressionException | ProtocolException (base) | - | ConnectionManuallyClosedException | ConnectionClosedException | + | ConnectionManuallyClosedException | ConnectionAbortedException, ConnectionClosedException | | ConnectionNotValidatedException | ProtocolException (base) | | EncapsulationException | MarshalException (base) | | EndpointParseException | ParseException | @@ -87,7 +87,7 @@ These are the changes since the Ice 3.7.10 release in [CHANGELOG-3.7.md](./CHANG base = was existing base class New local exceptions:\ - ConnectionClosedException, ConnectionIdleException, ParseException + ConnectionAbortedException, ConnectionClosedException, ConnectionIdleException, ParseException ## Slice Language Changes diff --git a/csharp/src/Ice/Connection.cs b/csharp/src/Ice/Connection.cs index 388c2526dd5..bd0f2717fcc 100644 --- a/csharp/src/Ice/Connection.cs +++ b/csharp/src/Ice/Connection.cs @@ -189,7 +189,7 @@ System.Threading.Tasks.Task heartbeatAsync( /// Throw an exception indicating the reason for connection closure. /// For example, /// CloseConnectionException is raised if the connection was closed gracefully, whereas - /// ConnectionClosedException is raised if the connection was manually closed by + /// ConnectionAbortedException/ConnectionClosedException is raised if the connection was manually closed by /// the application. This operation does nothing if the connection is not yet closed. /// void throwException(); diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 29799e75bd5..2a40d42f39f 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -162,7 +162,7 @@ public void close(ConnectionClose mode) if (mode == ConnectionClose.Forcefully) { setState(StateClosed, - new ConnectionClosedException( + new ConnectionAbortedException( "Connection close forcefully by the application.", closedByApplication: true)); } @@ -1267,6 +1267,7 @@ private void finish() // Trace the cause of unexpected connection closures // if (!(_exception is CloseConnectionException || + _exception is ConnectionAbortedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || @@ -1607,6 +1608,7 @@ private void setState(int state, LocalException ex) // Don't warn about certain expected exceptions. // if (!(_exception is CloseConnectionException || + _exception is ConnectionAbortedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || @@ -1769,6 +1771,7 @@ private void setState(int state) if (_observer is not null && state == StateClosed && _exception is not null) { if (!(_exception is CloseConnectionException || + _exception is ConnectionAbortedException || _exception is ConnectionClosedException || _exception is ConnectionIdleException || _exception is CommunicatorDestroyedException || diff --git a/csharp/src/Ice/Internal/RequestHandlerCache.cs b/csharp/src/Ice/Internal/RequestHandlerCache.cs index 9f06ebfae2b..97eb71680d7 100644 --- a/csharp/src/Ice/Internal/RequestHandlerCache.cs +++ b/csharp/src/Ice/Internal/RequestHandlerCache.cs @@ -237,9 +237,11 @@ private static int checkRetryAfterException(Ice.LocalException ex, Reference @re // Don't retry if the communicator is destroyed, object adapter is deactivated, // or connection is closed by the application. // - if (ex is Ice.CommunicatorDestroyedException || - ex is Ice.ObjectAdapterDeactivatedException || - (ex is Ice.ConnectionClosedException connectionClosedException && + if (ex is CommunicatorDestroyedException || + ex is ObjectAdapterDeactivatedException || + (ex is ConnectionAbortedException connectionAbortedException && + connectionAbortedException.closedByApplication) || + (ex is ConnectionClosedException connectionClosedException && connectionClosedException.closedByApplication)) { throw ex; diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index df994f05173..7ff4804ab07 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -382,7 +382,21 @@ public CommunicatorDestroyedException() } /// -/// This exception indicates that a connection was closed. +/// This exception indicates that a connection was closed forcefully. +/// +public sealed class ConnectionAbortedException : LocalException +{ + public bool closedByApplication { get; } + + public ConnectionAbortedException(string message, bool closedByApplication) + : base(message, innerException: null) => + this.closedByApplication = closedByApplication; + + public override string ice_id() => "::Ice::ConnectionAbortedException"; +} + +/// +/// This exception indicates that a connection was closed gracefully. /// public sealed class ConnectionClosedException : LocalException { diff --git a/csharp/test/Ice/ami/AllTests.cs b/csharp/test/Ice/ami/AllTests.cs index 3502383fd07..bd18d6b10a6 100644 --- a/csharp/test/Ice/ami/AllTests.cs +++ b/csharp/test/Ice/ami/AllTests.cs @@ -808,7 +808,7 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll { // // Local case: start an operation and then close the connection forcefully on the client side. - // There will be no retry and we expect the invocation to fail with ConnectionClosedException. + // There will be no retry and we expect the invocation to fail with ConnectionAbortedException. // p.ice_ping(); Connection con = p.ice_getConnection(); @@ -822,7 +822,7 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll await t; test(false); } - catch (ConnectionClosedException ex) + catch (ConnectionAbortedException ex) { test(ex.closedByApplication); } From fd4e4928ad667709f6ad9cd7f1c2252028a290fa Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Sun, 23 Jun 2024 19:58:49 -0400 Subject: [PATCH 16/21] Fix RFE --- csharp/src/Ice/CurrentExtensions.cs | 29 +++++++++++------------------ csharp/src/Ice/LocalExceptions.cs | 26 ++++++++++++++------------ csharp/test/Ice/invoke/BlobjectI.cs | 12 ++---------- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/csharp/src/Ice/CurrentExtensions.cs b/csharp/src/Ice/CurrentExtensions.cs index 98d890ddbc6..cbb8bf42e25 100644 --- a/csharp/src/Ice/CurrentExtensions.cs +++ b/csharp/src/Ice/CurrentExtensions.cs @@ -157,39 +157,32 @@ OutgoingResponse createOutgoingResponseCore(System.Exception exc) _ => throw new Ice.MarshalException("Unexpected exception type") }; - if (rfe.id.name.Length == 0) + Identity id = rfe.id; + string facet = rfe.facet; + if (id.name.Length == 0) { - rfe.id = current.id; + id = current.id; + facet = current.facet; } + string operation = rfe.operation.Length == 0 ? current.operation : rfe.operation; - if (rfe.facet.Length == 0 && current.facet.Length > 0) - { - rfe.facet = current.facet; - } - - if (rfe.operation.Length == 0 && current.operation.Length > 0) - { - rfe.operation = current.operation; - } - - // Called after fixing id, facet and operation. - exceptionMessage = rfe.ToString(); + exceptionMessage = RequestFailedException.createMessage(rfe.GetType().Name, id, facet, operation); if (current.requestId != 0) { ostr.writeByte((byte)replyStatus); - Identity.ice_write(ostr, rfe.id); + Identity.ice_write(ostr, id); - if (rfe.facet.Length == 0) + if (facet.Length == 0) { ostr.writeStringSeq([]); } else { - ostr.writeStringSeq([rfe.facet]); + ostr.writeStringSeq([facet]); } - ostr.writeString(rfe.operation); + ostr.writeString(operation); } break; diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 7ff4804ab07..5ec89394a79 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -16,15 +16,12 @@ namespace Ice; /// public class RequestFailedException : LocalException { - public Identity id { get; set; } - public string facet { get; set; } - public string operation { get; set; } + public Identity id { get; } + public string facet { get; } + public string operation { get; } - // We can't set the message in the constructor because id/facet/operation can be set after construction. - public override string Message => - $"{base.Message} id = '{Util.identityToString(id)}', facet = '{facet}', operation = '{operation}'"; - - protected RequestFailedException(Identity id, string facet, string operation) + protected RequestFailedException(string typeName, Identity id, string facet, string operation) + : base(createMessage(typeName, id, facet, operation)) { this.id = id; this.facet = facet; @@ -32,9 +29,14 @@ protected RequestFailedException(Identity id, string facet, string operation) } protected RequestFailedException() - : this(new Identity(), "", "") { + this.id = new Identity(); + this.facet = ""; + this.operation = ""; } + + internal static string createMessage(string typeName, Identity id, string facet, string operation) => + $"Dispatch failed with {typeName} {{ id = '{Util.identityToString(id)}', facet = '{facet}', operation = '{operation}' }}"; } /// @@ -47,7 +49,7 @@ public ObjectNotExistException() } public ObjectNotExistException(Identity id, string facet, string operation) - : base(id, facet, operation) + : base(nameof(ObjectNotExistException), id, facet, operation) { } @@ -64,7 +66,7 @@ public FacetNotExistException() } public FacetNotExistException(Identity id, string facet, string operation) - : base(id, facet, operation) + : base(nameof(FacetNotExistException), id, facet, operation) { } @@ -82,7 +84,7 @@ public OperationNotExistException() } public OperationNotExistException(Identity id, string facet, string operation) - : base(id, facet, operation) + : base(nameof(OperationNotExistException), id, facet, operation) { } diff --git a/csharp/test/Ice/invoke/BlobjectI.cs b/csharp/test/Ice/invoke/BlobjectI.cs index 82cb029368e..dd656b71d42 100644 --- a/csharp/test/Ice/invoke/BlobjectI.cs +++ b/csharp/test/Ice/invoke/BlobjectI.cs @@ -63,11 +63,7 @@ public override bool } else { - Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); - ex.id = current.id; - ex.facet = current.facet; - ex.operation = current.operation; - throw ex; + throw new Ice.OperationNotExistException(); } } } @@ -122,11 +118,7 @@ public override Task } else { - Ice.OperationNotExistException ex = new Ice.OperationNotExistException(); - ex.id = current.id; - ex.facet = current.facet; - ex.operation = current.operation; - throw ex; + throw new Ice.OperationNotExistException(); } } } From e1618414b59c08748d48c6d5e8fde44fb0b9411d Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 24 Jun 2024 09:23:20 -0400 Subject: [PATCH 17/21] Reformat --- csharp/src/Ice/InputStream.cs | 2 +- csharp/src/Ice/Internal/ReferenceFactory.cs | 4 ++-- csharp/src/Ice/LocalExceptions.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/csharp/src/Ice/InputStream.cs b/csharp/src/Ice/InputStream.cs index b2b4ee69121..55b65427d0d 100644 --- a/csharp/src/Ice/InputStream.cs +++ b/csharp/src/Ice/InputStream.cs @@ -3501,7 +3501,7 @@ internal override void skipSlice() if (_current.sliceType == SliceType.ValueSlice) { throw new MarshalException( - $"Cannot find value factory for type ID '{ _current.typeId}' and compact format prevents slicing."); + $"Cannot find value factory for type ID '{_current.typeId}' and compact format prevents slicing."); } else { diff --git a/csharp/src/Ice/Internal/ReferenceFactory.cs b/csharp/src/Ice/Internal/ReferenceFactory.cs index 14d41ae65ae..c5786bd6417 100644 --- a/csharp/src/Ice/Internal/ReferenceFactory.cs +++ b/csharp/src/Ice/Internal/ReferenceFactory.cs @@ -329,7 +329,7 @@ public Reference create(string s, string propertyPrefix) { if (argument == null) { - throw new ParseException($"no argument provided for -p option in proxy string '{s}'"); + throw new ParseException($"no argument provided for -p option in proxy string '{s}'"); } try @@ -345,7 +345,7 @@ public Reference create(string s, string propertyPrefix) default: { - throw new ParseException($"unknown option '{option}' in proxy string '{s}'"); + throw new ParseException($"unknown option '{option}' in proxy string '{s}'"); } } } diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 5ec89394a79..46174c26e57 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -505,8 +505,8 @@ public sealed class NotRegisteredException : LocalException public string kindOfObject { get; } public string id { get; } - public NotRegisteredException(string kindOfObject, string id) - : base($"No {kindOfObject} is registered with ID '{id}'.") + public NotRegisteredException(string kindOfObject, string id) + : base($"No {kindOfObject} is registered with ID '{id}'.") { this.kindOfObject = kindOfObject; this.id = id; From 2b660862267a8783dfcfa7d4f23bbc390212fb77 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 24 Jun 2024 15:38:32 -0400 Subject: [PATCH 18/21] Update csharp/src/IceBox/Service.cs Co-authored-by: Jose --- csharp/src/IceBox/Service.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csharp/src/IceBox/Service.cs b/csharp/src/IceBox/Service.cs index f4e43a6df8d..a580a825fe5 100644 --- a/csharp/src/IceBox/Service.cs +++ b/csharp/src/IceBox/Service.cs @@ -6,7 +6,7 @@ namespace IceBox; /// /// This exception is a general failure notification. -/// It is thrown for errors such as a service encountering an error during initialization, or the service manager +/// It is thrown for errors such as a service encountering an error during initialization, or the service manager /// being unable to load a service executable. /// public sealed class FailureException : Ice.LocalException From 316bb738b6352d968867869c954d893126d166d1 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 24 Jun 2024 15:54:34 -0400 Subject: [PATCH 19/21] Fix review comment + cross-test failures --- cpp/test/Ice/proxy/AllTests.cpp | 12 ++++++++---- csharp/src/Ice/SSL/TrustManager.cs | 2 +- csharp/test/Ice/proxy/AllTests.cs | 5 ++++- java/test/src/main/java/test/Ice/proxy/AllTests.java | 12 ++++++++---- swift/test/Ice/proxy/AllTests.swift | 10 ++++++---- 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/cpp/test/Ice/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 9b09e31f19c..f93f1fcb10e 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -1008,8 +1008,10 @@ allTests(TestHelper* helper) } catch (const Ice::UnknownLocalException& ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.find("UnsupportedEncodingException") != string::npos); + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.find("MarshalException") != string::npos || + ex.unknown.find("UnsupportedEncodingException") != string::npos); } try @@ -1029,8 +1031,10 @@ allTests(TestHelper* helper) } catch (const Ice::UnknownLocalException& ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.find("UnsupportedEncodingException") != string::npos); + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.find("MarshalException") != string::npos || + ex.unknown.find("UnsupportedEncodingException") != string::npos); } cout << "ok" << endl; diff --git a/csharp/src/Ice/SSL/TrustManager.cs b/csharp/src/Ice/SSL/TrustManager.cs index 7abcee23848..d484ec44478 100644 --- a/csharp/src/Ice/SSL/TrustManager.cs +++ b/csharp/src/Ice/SSL/TrustManager.cs @@ -45,7 +45,7 @@ internal TrustManager(Ice.Communicator communicator) } catch (ParseException ex) { - throw new PluginInitializationException($"IceSSL: invalid property {key}", ex); + throw new InitializationException($"IceSSL: invalid property {key}", ex); } } diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 3b1a5df1cd7..49af832d2c4 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -865,7 +865,10 @@ public class AllTests : global::Test.AllTests } catch (Ice.UnknownLocalException ex) { - test(ex.unknown.Contains("MarshalException")); // encoding not supported + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.Contains("MarshalException") || + ex.unknown.Contains("UnsupportedEncodingException")); } try diff --git a/java/test/src/main/java/test/Ice/proxy/AllTests.java b/java/test/src/main/java/test/Ice/proxy/AllTests.java index e9bb0f55d82..0cf72656137 100644 --- a/java/test/src/main/java/test/Ice/proxy/AllTests.java +++ b/java/test/src/main/java/test/Ice/proxy/AllTests.java @@ -920,8 +920,10 @@ public static MyClassPrx allTests(test.TestHelper helper) { cl.ice_invoke("ice_ping", com.zeroc.Ice.OperationMode.Normal, inEncaps); test(false); } catch (com.zeroc.Ice.UnknownLocalException ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.indexOf("UnsupportedEncodingException") > 0); + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.indexOf("MarshalException") > 0 + || ex.unknown.indexOf("UnsupportedEncodingException") > 0); } try { @@ -936,8 +938,10 @@ public static MyClassPrx allTests(test.TestHelper helper) { cl.ice_invoke("ice_ping", com.zeroc.Ice.OperationMode.Normal, inEncaps); test(false); } catch (com.zeroc.Ice.UnknownLocalException ex) { - // The server thrown an UnsupportedEncodingException - test(ex.unknown.indexOf("UnsupportedEncodingException") > 0); + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.indexOf("MarshalException") > 0 + || ex.unknown.indexOf("UnsupportedEncodingException") > 0); } out.println("ok"); diff --git a/swift/test/Ice/proxy/AllTests.swift b/swift/test/Ice/proxy/AllTests.swift index b7509bd3751..899b0c9afb2 100644 --- a/swift/test/Ice/proxy/AllTests.swift +++ b/swift/test/Ice/proxy/AllTests.swift @@ -743,8 +743,9 @@ public func allTests(_ helper: TestHelper) throws -> MyClassPrx { _ = try cl.ice_invoke(operation: "ice_ping", mode: Ice.OperationMode.Normal, inEncaps: inEncaps) try test(false) } catch let ex as Ice.UnknownLocalException { - // The server thrown an UnsupportedEncodingException - try test(ex.unknown.contains("UnsupportedEncodingException")) + // TODO: remove UnsupportedEncodingException + try test( + ex.unknown.contains("MarshalException") || ex.unknown.contains("UnsupportedEncodingException")) } do { @@ -759,8 +760,9 @@ public func allTests(_ helper: TestHelper) throws -> MyClassPrx { _ = try cl.ice_invoke(operation: "ice_ping", mode: Ice.OperationMode.Normal, inEncaps: inEncaps) try test(false) } catch let ex as Ice.UnknownLocalException { - // The server thrown an UnsupportedEncodingException - try test(ex.unknown.contains("UnsupportedEncodingException")) + // TODO: remove UnsupportedEncodingException + try test( + ex.unknown.contains("MarshalException") || ex.unknown.contains("UnsupportedEncodingException")) } writer.writeLine("ok") From 29b026d3324808a482fa4d9145b93968b2f4faf9 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 24 Jun 2024 21:24:53 -0400 Subject: [PATCH 20/21] Fix cross-test --- csharp/test/Ice/proxy/AllTests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index 49af832d2c4..3791cc3afca 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -888,7 +888,10 @@ public class AllTests : global::Test.AllTests } catch (Ice.UnknownLocalException ex) { - test(ex.unknown.Contains("MarshalException")); // encoding not supported + // TODO: remove UnsupportedEncodingException + test( + ex.unknown.Contains("MarshalException") || + ex.unknown.Contains("UnsupportedEncodingException")); } output.WriteLine("ok"); From 28cdd3c51dbc62a7f6ffb3176e605f4dd3e1b8f3 Mon Sep 17 00:00:00 2001 From: Bernard Normier Date: Mon, 24 Jun 2024 21:28:40 -0400 Subject: [PATCH 21/21] Remove bogus innerException parameter --- csharp/src/Ice/LocalExceptions.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/csharp/src/Ice/LocalExceptions.cs b/csharp/src/Ice/LocalExceptions.cs index 46174c26e57..f857134447c 100644 --- a/csharp/src/Ice/LocalExceptions.cs +++ b/csharp/src/Ice/LocalExceptions.cs @@ -98,8 +98,8 @@ public class UnknownException : LocalException { public string unknown => Message; - public UnknownException(string message, System.Exception? innerException = null) - : base(message, innerException) + public UnknownException(string message) + : base(message) { } @@ -112,8 +112,8 @@ public UnknownException(string message, System.Exception? innerException = null) /// public sealed class UnknownLocalException : UnknownException { - public UnknownLocalException(string message, LocalException? innerException = null) - : base(message, innerException) + public UnknownLocalException(string message) + : base(message) { } @@ -127,7 +127,7 @@ public UnknownLocalException(string message, LocalException? innerException = nu public sealed class UnknownUserException : UnknownException { public UnknownUserException(string message) - : base(message, innerException: null) + : base(message) { }