From 8a8a93e6d1b257f1f627bcc21d6554df6aa51ed9 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 25 Jul 2024 10:04:54 +0200 Subject: [PATCH] JavaScript exception mapping fixes (#2562) --- cpp/src/slice2js/Gen.cpp | 2 +- js/src/Ice/AsyncResult.js | 4 +- js/src/Ice/Communicator.js | 2 +- js/src/Ice/ConnectRequestHandler.js | 2 +- js/src/Ice/ConnectionI.js | 4 +- js/src/Ice/DefaultsAndOverrides.js | 2 +- js/src/Ice/EndpointFactoryManager.js | 2 +- js/src/Ice/ExUtil.js | 2 +- js/src/Ice/Exception.d.ts | 16 - js/src/Ice/Exception.js | 94 +-- js/src/Ice/IPEndpointI.js | 2 +- js/src/Ice/IdentityUtil.js | 2 +- js/src/Ice/ImplicitContext.js | 2 +- js/src/Ice/IncomingAsync.js | 5 +- js/src/Ice/Initialize.js | 2 +- js/src/Ice/InstanceExtensions.js | 4 +- js/src/Ice/LocalException.d.ts | 679 +------------------- js/src/Ice/LocalException.js | 786 +---------------------- js/src/Ice/LocalExceptions.d.ts | 687 +++++++++++++++++++++ js/src/Ice/LocalExceptions.js | 788 ++++++++++++++++++++++++ js/src/Ice/LocatorInfo.js | 5 +- js/src/Ice/ObjectAdapter.js | 2 +- js/src/Ice/ObjectAdapterFactory.js | 2 +- js/src/Ice/ObjectPrxExtensions.js | 9 +- js/src/Ice/OpaqueEndpoint.js | 2 +- js/src/Ice/Operation.js | 2 +- js/src/Ice/OutgoingAsync.js | 6 +- js/src/Ice/OutgoingConnectionFactory.js | 4 +- js/src/Ice/Properties.js | 2 +- js/src/Ice/Protocol.js | 6 +- js/src/Ice/Reference.js | 2 +- js/src/Ice/ReferenceFactory.js | 2 +- js/src/Ice/RetryException.js | 2 +- js/src/Ice/RetryQueue.js | 2 +- js/src/Ice/RouterInfo.js | 2 +- js/src/Ice/ServantManager.js | 2 +- js/src/Ice/Stream.js | 5 +- js/src/Ice/TcpEndpointI.js | 2 +- js/src/Ice/TcpTransceiver.js | 2 +- js/src/Ice/Timer.js | 2 +- js/src/Ice/UserException.d.ts | 18 + js/src/Ice/UserException.js | 78 +++ js/src/Ice/ValueFactoryManager.js | 2 +- js/src/Ice/WSEndpoint.js | 2 +- js/src/Ice/WSTransceiver.js | 2 +- js/src/Ice/index.d.ts | 2 + js/src/Ice/index.js | 4 + 47 files changed, 1640 insertions(+), 1618 deletions(-) create mode 100644 js/src/Ice/LocalExceptions.d.ts create mode 100644 js/src/Ice/LocalExceptions.js create mode 100644 js/src/Ice/UserException.d.ts create mode 100644 js/src/Ice/UserException.js diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index b2ad7190ba8..303a521ddea 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -948,7 +948,7 @@ Slice::Gen::ImportVisitor::writeImports(const UnitPtr& p) if (_seenUserException) { - jsIceImports.insert("Exception"); + jsIceImports.insert("UserException"); jsIceImports.insert("TypeRegistry"); } diff --git a/js/src/Ice/AsyncResult.js b/js/src/Ice/AsyncResult.js index 00eb565d21d..b7b3bfc2bb9 100644 --- a/js/src/Ice/AsyncResult.js +++ b/js/src/Ice/AsyncResult.js @@ -5,8 +5,8 @@ import { AsyncResultBase } from "./AsyncResultBase.js"; import { OutputStream } from "./Stream.js"; import { Protocol } from "./Protocol.js"; -import { UserException } from "./Exception.js"; -import { InvocationCanceledException } from "./LocalException.js"; +import { UserException } from "./UserException.js"; +import { InvocationCanceledException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; export class AsyncResult extends AsyncResultBase { diff --git a/js/src/Ice/Communicator.js b/js/src/Ice/Communicator.js index e0aa01d18a9..20c87bc59a3 100644 --- a/js/src/Ice/Communicator.js +++ b/js/src/Ice/Communicator.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { CommunicatorDestroyedException } from "./LocalException.js"; +import { CommunicatorDestroyedException } from "./LocalExceptions.js"; import { generateUUID } from "./UUID.js"; import { identityToString } from "./IdentityUtil.js"; import { Promise } from "./Promise.js"; diff --git a/js/src/Ice/ConnectRequestHandler.js b/js/src/Ice/ConnectRequestHandler.js index 738cdd36b96..24d992751e3 100644 --- a/js/src/Ice/ConnectRequestHandler.js +++ b/js/src/Ice/ConnectRequestHandler.js @@ -3,7 +3,7 @@ // import { AsyncStatus } from "./AsyncStatus.js"; -import { LocalException } from "./Exception.js"; +import { LocalException } from "./LocalException.js"; import { RetryException } from "./RetryException.js"; import { Debug } from "./Debug.js"; diff --git a/js/src/Ice/ConnectionI.js b/js/src/Ice/ConnectionI.js index 3ef6e34d539..18de9a84fa2 100644 --- a/js/src/Ice/ConnectionI.js +++ b/js/src/Ice/ConnectionI.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { LocalException } from "./Exception.js"; +import { LocalException } from "./LocalException.js"; import { IllegalMessageSizeException, ObjectAdapterDeactivatedException, @@ -21,7 +21,7 @@ import { ConnectionNotValidatedException, UnknownMessageException, UnknownException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { ConnectionClose } from "./Connection.js"; diff --git a/js/src/Ice/DefaultsAndOverrides.js b/js/src/Ice/DefaultsAndOverrides.js index b9885ee7960..2043ca00287 100644 --- a/js/src/Ice/DefaultsAndOverrides.js +++ b/js/src/Ice/DefaultsAndOverrides.js @@ -5,7 +5,7 @@ import { FormatType } from "./FormatType.js"; import { EndpointSelectionType } from "./EndpointSelectionType.js"; import { Protocol, stringToEncodingVersion, encodingVersionToString } from "./Protocol.js"; -import { EndpointSelectionTypeParseException } from "./LocalException.js"; +import { EndpointSelectionTypeParseException } from "./LocalExceptions.js"; import { TcpTransceiver } from "./TcpTransceiver.js"; export class DefaultsAndOverrides { diff --git a/js/src/Ice/EndpointFactoryManager.js b/js/src/Ice/EndpointFactoryManager.js index 67561b0bdf7..9aa6f9ba769 100644 --- a/js/src/Ice/EndpointFactoryManager.js +++ b/js/src/Ice/EndpointFactoryManager.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { EndpointParseException } from "./LocalException.js"; +import { EndpointParseException } from "./LocalExceptions.js"; import { StringUtil } from "./StringUtil.js"; import { OpaqueEndpointI } from "./OpaqueEndpoint.js"; import { Protocol } from "./Protocol.js"; diff --git a/js/src/Ice/ExUtil.js b/js/src/Ice/ExUtil.js index 5050e4a7c3f..307bd777465 100644 --- a/js/src/Ice/ExUtil.js +++ b/js/src/Ice/ExUtil.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { UnexpectedObjectException, MemoryLimitException } from "./LocalException.js"; +import { UnexpectedObjectException, MemoryLimitException } from "./LocalExceptions.js"; export function throwUOE(expectedType, v) { const type = v.ice_id(); diff --git a/js/src/Ice/Exception.d.ts b/js/src/Ice/Exception.d.ts index 981b5794536..47fe2215def 100644 --- a/js/src/Ice/Exception.d.ts +++ b/js/src/Ice/Exception.d.ts @@ -24,21 +24,5 @@ declare module "ice" { ice_cause: string | Error; } - - /** - * Base class for all Ice run-time exceptions. - */ - abstract class LocalException extends Exception {} - - /** - * Base class for all Ice user exceptions. - */ - abstract class UserException extends Exception { - /** - * Obtains the Slice type ID of this exception. - * @return The fully-scoped type ID. - */ - static ice_staticId(): string; - } } } diff --git a/js/src/Ice/Exception.js b/js/src/Ice/Exception.js index 4eb91e9b3e5..9804140a054 100644 --- a/js/src/Ice/Exception.js +++ b/js/src/Ice/Exception.js @@ -38,7 +38,7 @@ const toString = function (key, object, objectTable, ident) { // // Ice.Exception // -class Exception extends Error { +export class Exception extends Error { constructor(cause) { super(); if (cause) { @@ -86,95 +86,3 @@ class Exception extends Error { } } } - -// -// Ice.LocalException -// -class LocalException extends Exception { - constructor(cause) { - super(cause); - Exception.captureStackTrace(this); - } - - static get _id() { - return "::Ice::LocalException"; - } -} - -// -// Ice.UserException -// -class UserException extends Exception { - constructor(cause) { - super(cause); - Exception.captureStackTrace(this); - } - - static get _id() { - return "::Ice::UserException"; - } - - _write(os) { - os.startException(); - writeImpl(this, os, this._mostDerivedType()); - os.endException(); - } - - _read(is) { - is.startException(); - readImpl(this, is, this._mostDerivedType()); - is.endException(); - } - - _usesClasses() { - return false; - } - - _mostDerivedType() { - return UserException; - } -} - -// -// Private methods -// - -const writeImpl = function (obj, os, type) { - // - // The writeImpl method is a recursive method that goes down the - // class hierarchy to marshal each slice of the class using the - // generated _writeMemberImpl method. - // - - if (type === undefined || type === UserException) { - return; // Don't marshal anything for Ice.UserException - } - - os.startSlice(type._id, -1, type._parent === UserException); - if (type.prototype.hasOwnProperty("_writeMemberImpl")) { - type.prototype._writeMemberImpl.call(obj, os); - } - os.endSlice(); - writeImpl(obj, os, type._parent); -}; - -const readImpl = function (obj, is, type) { - // - // The readImpl method is a recursive method that goes down the - // class hierarchy to marshal each slice of the class using the - // generated _readMemberImpl method. - // - - if (type === undefined || type === UserException) { - return; // Don't marshal anything for UserException - } - - is.startSlice(); - if (type.prototype.hasOwnProperty("_readMemberImpl")) { - type.prototype._readMemberImpl.call(obj, is); - } - is.endSlice(); - readImpl(obj, is, type._parent); -}; - -export { Exception, LocalException, UserException }; diff --git a/js/src/Ice/IPEndpointI.js b/js/src/Ice/IPEndpointI.js index 62d69d58544..62cc7da112e 100644 --- a/js/src/Ice/IPEndpointI.js +++ b/js/src/Ice/IPEndpointI.js @@ -3,7 +3,7 @@ // import { Address } from "./Address.js"; -import { EndpointParseException } from "./LocalException.js"; +import { EndpointParseException } from "./LocalExceptions.js"; import { HashUtil } from "./HashUtil.js"; import { StringUtil } from "./StringUtil.js"; import { EndpointI } from "./EndpointI.js"; diff --git a/js/src/Ice/IdentityUtil.js b/js/src/Ice/IdentityUtil.js index c5f47983c6a..d298d3d2a12 100644 --- a/js/src/Ice/IdentityUtil.js +++ b/js/src/Ice/IdentityUtil.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { IdentityParseException } from "./LocalException.js"; +import { IdentityParseException } from "./LocalExceptions.js"; import { StringUtil } from "./StringUtil.js"; import { Ice as Ice_Identity } from "./Identity.js"; import { ToStringMode } from "./ToStringMode.js"; diff --git a/js/src/Ice/ImplicitContext.js b/js/src/Ice/ImplicitContext.js index 75a02eade0f..b44d85e3013 100644 --- a/js/src/Ice/ImplicitContext.js +++ b/js/src/Ice/ImplicitContext.js @@ -5,7 +5,7 @@ import { Ice as Ice_Context } from "./Context.js"; const { Context, ContextHelper } = Ice_Context; -import { InitializationException } from "./LocalException.js"; +import { InitializationException } from "./LocalExceptions.js"; // // The base class for all ImplicitContext implementations diff --git a/js/src/Ice/IncomingAsync.js b/js/src/Ice/IncomingAsync.js index de7aacdbc88..85072012487 100644 --- a/js/src/Ice/IncomingAsync.js +++ b/js/src/Ice/IncomingAsync.js @@ -11,7 +11,8 @@ import { Ice as Ice_Identity } from "./Identity.js"; const { Identity } = Ice_Identity; import { identityToString } from "./IdentityUtil.js"; import { FormatType } from "./FormatType.js"; -import { LocalException, UserException } from "./Exception.js"; +import { LocalException } from "./LocalException.js"; +import { UserException } from "./UserException.js"; import { FacetNotExistException, MarshalException, @@ -21,7 +22,7 @@ import { UnknownException, UnknownLocalException, UnknownUserException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { Protocol } from "./Protocol.js"; import { OutputStream } from "./Stream.js"; diff --git a/js/src/Ice/Initialize.js b/js/src/Ice/Initialize.js index 016c1ad3f28..0e86d4e4b46 100644 --- a/js/src/Ice/Initialize.js +++ b/js/src/Ice/Initialize.js @@ -4,7 +4,7 @@ import { Communicator } from "./Communicator.js"; import { Protocol } from "./Protocol.js"; -import { InitializationException } from "./LocalException.js"; +import { InitializationException } from "./LocalExceptions.js"; import { Properties } from "./Properties.js"; export class InitializationData { diff --git a/js/src/Ice/InstanceExtensions.js b/js/src/Ice/InstanceExtensions.js index 8d5bdd12b09..65d60a6ed40 100644 --- a/js/src/Ice/InstanceExtensions.js +++ b/js/src/Ice/InstanceExtensions.js @@ -17,8 +17,8 @@ import { RouterManager } from "./RouterManager.js"; import { Timer } from "./Timer.js"; import { TraceLevels } from "./TraceLevels.js"; import { ValueFactoryManager } from "./ValueFactoryManager.js"; -import { LocalException } from "./Exception.js"; -import { CommunicatorDestroyedException, InitializationException } from "./LocalException.js"; +import { LocalException } from "./LocalException.js"; +import { CommunicatorDestroyedException, InitializationException } from "./LocalExceptions.js"; import { getProcessLogger } from "./ProcessLogger.js"; import { ToStringMode } from "./ToStringMode.js"; import { ProtocolInstance } from "./ProtocolInstance.js"; diff --git a/js/src/Ice/LocalException.d.ts b/js/src/Ice/LocalException.d.ts index 38233a9db13..bc84c204201 100644 --- a/js/src/Ice/LocalException.d.ts +++ b/js/src/Ice/LocalException.d.ts @@ -5,683 +5,8 @@ declare module "ice" { namespace Ice { /** - * This exception is raised when a failure occurs during initialization. + * Base class for all Ice run-time exceptions. */ - class InitializationException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - reason: string; - } - - /** - * 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. - */ - class AlreadyRegisteredException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param kindOfObject The kind of object that could not be removed: "servant", "facet", "object", "default servant", "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". - * @param id The ID (or name) of the object that is registered already. - * @param ice_cause The error that cause this exception. - */ - constructor(kindOfObject?: string, id?: string, ice_cause?: string | Error); - kindOfObject: string; - id: string; - } - - /** - * 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. - */ - class NotRegisteredException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param kindOfObject The kind of object that could not be removed: "servant", "facet", "object", "default servant", "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". - * @param id The ID (or name) of the object that could not be removed. - * @param ice_cause The error that cause this exception. - */ - constructor(kindOfObject?: string, id?: string, ice_cause?: string | Error); - kindOfObject: string; - id: string; - } - - /** - * 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. - */ - class TwowayOnlyException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param operation The name of the operation that was invoked. - * @param ice_cause The error that cause this exception. - */ - constructor(operation?: string, ice_cause?: string | Error); - operation: string; - } - - /** - * 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. - */ - class UnknownException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param unknown This field is set to the textual representation of the unknown exception if available. - * @param ice_cause The error that cause this exception. - */ - constructor(unknown?: string, ice_cause?: string | Error); - unknown: string; - } - - /** - * 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 - * {@link UnknownLocalException}. The only exception to this rule are all exceptions derived from - * {@link RequestFailedException}, which are transmitted by the Ice protocol even though they are declared - * local. - */ - class UnknownLocalException extends UnknownException { - /** - * One-shot constructor to initialize all data members. - * @param unknown This field is set to the textual representation of the unknown exception if available. - * @param ice_cause The error that cause this exception. - */ - constructor(unknown?: string, ice_cause?: string | Error); - } - - /** - * 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 {@link 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. - */ - class UnknownUserException extends UnknownException { - /** - * One-shot constructor to initialize all data members. - * @param unknown This field is set to the textual representation of the unknown exception if available. - * @param ice_cause The error that cause this exception. - */ - constructor(unknown?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if the {@link Communicator} has been destroyed. - * @see Communicator#destroy - */ - class CommunicatorDestroyedException extends LocalException {} - - /** - * This exception is raised if an attempt is made to use a deactivated {@link ObjectAdapter}. - * @see ObjectAdapter#deactivate - * @see Communicator#shutdown - */ - class ObjectAdapterDeactivatedException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param name Name of the adapter. - * @param ice_cause The error that cause this exception. - */ - constructor(name?: string, ice_cause?: string | Error); - name: string; - } - - /** - * This exception is raised if an {@link ObjectAdapter} cannot be activated. This happens if the {@link Locator} - * detects another active {@link ObjectAdapter} with the same adapter id. - */ - class ObjectAdapterIdInUseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param id Adapter ID. - * @param ice_cause The error that cause this exception. - */ - constructor(id?: string, ice_cause?: string | Error); - id: string; - } - - /** - * This exception is raised if no suitable endpoint is available. - */ - class NoEndpointException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param proxy The stringified proxy for which no suitable endpoint is available. - * @param ice_cause The error that cause this exception. - */ - constructor(proxy?: string, ice_cause?: string | Error); - proxy: string; - } - - /** - * This exception is raised if there was an error while parsing an endpoint. - */ - class EndpointParseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param str Describes the failure and includes the string that could not be parsed. - * @param ice_cause The error that cause this exception. - */ - constructor(str?: string, ice_cause?: string | Error); - str: string; - } - - /** - * This exception is raised if there was an error while parsing an endpoint selection type. - */ - class EndpointSelectionTypeParseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param str Describes the failure and includes the string that could not be parsed. - * @param ice_cause The error that cause this exception. - */ - constructor(str?: string, ice_cause?: string | Error); - str: string; - } - - /** - * This exception is raised if there was an error while parsing a version. - */ - class VersionParseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param str Describes the failure and includes the string that could not be parsed. - * @param ice_cause The error that cause this exception. - */ - constructor(str?: string, ice_cause?: string | Error); - str: string; - } - - /** - * This exception is raised if there was an error while parsing a stringified identity. - */ - class IdentityParseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param str Describes the failure and includes the string that could not be parsed. - * @param ice_cause The error that cause this exception. - */ - constructor(str?: string, ice_cause?: string | Error); - str: string; - } - - /** - * This exception is raised if there was an error while parsing a stringified proxy. - */ - class ProxyParseException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param str Describes the failure and includes the string that could not be parsed. - * @param ice_cause The error that cause this exception. - */ - constructor(str?: string, ice_cause?: string | Error); - str: string; - } - - /** - * This exception is raised if an identity with an empty name is encountered. - */ - class IllegalIdentityException extends LocalException {} - - /** - * This exception is raised to reject an illegal servant (typically a null servant). - */ - class IllegalServantException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param reason Describes why this servant is illegal. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - reason: string; - } - - /** - * This exception is raised if a request failed. This exception, and all exceptions derived from - * {@link RequestFailedException}, are transmitted by the Ice protocol, even though they are declared - * local. - */ - class RequestFailedException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param id The identity of the Ice Object to which the request was sent. - * @param facet The facet to which the request was sent. - * @param operation The operation name of the request. - * @param ice_cause The error that cause this exception. - */ - constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); - id: Identity; - facet: string; - operation: string; - } - - /** - * This exception is raised if an object does not exist on the server, that is, if no facets with the given identity - * exist. - */ - class ObjectNotExistException extends RequestFailedException { - /** - * One-shot constructor to initialize all data members. - * @param id The identity of the Ice Object to which the request was sent. - * @param facet The facet to which the request was sent. - * @param operation The operation name of the request. - * @param ice_cause The error that cause this exception. - */ - constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if no facet with the given name exists, but at least one facet with the given identity - * exists. - */ - class FacetNotExistException extends RequestFailedException { - /** - * One-shot constructor to initialize all data members. - * @param id The identity of the Ice Object to which the request was sent. - * @param facet The facet to which the request was sent. - * @param operation The operation name of the request. - * @param ice_cause The error that cause this exception. - */ - constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); - } - - /** - * 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. - */ - class OperationNotExistException extends RequestFailedException { - /** - * One-shot constructor to initialize all data members. - * @param id The identity of the Ice Object to which the request was sent. - * @param facet The facet to which the request was sent. - * @param operation The operation name of the request. - * @param ice_cause The error that cause this exception. - */ - constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); - } - - /** - * 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, {@link SyscallException#error} should be inspected. - */ - class SyscallException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param error The error number describing the system exception. - * @param ice_cause The error that cause this exception. - */ - constructor(error?: number, ice_cause?: string | Error); - error: number; - } - - /** - * This exception indicates socket errors. - */ - class SocketException extends SyscallException { - /** - * One-shot constructor to initialize all data members. - * @param error The error number describing the system exception. - * @param ice_cause The error that cause this exception. - */ - constructor(error?: number, ice_cause?: string | Error); - } - - /** - * This exception indicates connection failures. - */ - class ConnectFailedException extends SocketException { - /** - * One-shot constructor to initialize all data members. - * @param error The error number describing the system exception. - * @param ice_cause The error that cause this exception. - */ - constructor(error?: number, ice_cause?: string | Error); - } - - /** - * This exception indicates a connection failure for which the server host actively refuses a connection. - */ - class ConnectionRefusedException extends ConnectFailedException { - /** - * One-shot constructor to initialize all data members. - * @param error The error number describing the system exception. - * @param ice_cause The error that cause this exception. - */ - constructor(error?: number, ice_cause?: string | Error); - } - - /** - * This exception indicates a lost connection. - */ - class ConnectionLostException extends SocketException { - /** - * One-shot constructor to initialize all data members. - * @param error The error number describing the system exception. - * @param ice_cause The error that cause this exception. - */ - constructor(error?: number, ice_cause?: string | Error); - } - - /** - * This exception indicates a timeout condition. - */ - class TimeoutException extends LocalException {} - - /** - * This exception indicates a connection establishment timeout condition. - */ - class ConnectTimeoutException extends TimeoutException {} - - /** - * This exception indicates a connection closure timeout condition. - */ - class CloseTimeoutException extends TimeoutException {} - - /** - * This exception indicates that a connection was closed gracefully. - */ - class ConnectionClosedException extends LocalException {} - - /** - * This exception indicates that a connection was aborted by the idle check. - */ - class ConnectionIdleException extends LocalException {} - - /** - * This exception indicates that an invocation failed because it timed out. - */ - class InvocationTimeoutException extends TimeoutException {} - - /** - * This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. - */ - class InvocationCanceledException extends LocalException {} - - /** - * A generic exception base for all kinds of protocol error conditions. - */ - class ProtocolException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - reason: string; - } - - /** - * This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). - */ - class BadMagicException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param badMagic A sequence containing the first four bytes of the incorrect message. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, badMagic?: ByteSeq, ice_cause?: string | Error); - badMagic: ByteSeq; - } - - /** - * This exception indicates an unsupported protocol version. - */ - class UnsupportedProtocolException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param bad The version of the unsupported protocol. - * @param supported The version of the protocol that is supported. - * @param ice_cause The error that cause this exception. - */ - constructor( - reason?: string, - bad?: ProtocolVersion, - supported?: ProtocolVersion, - ice_cause?: string | Error, - ); - bad: ProtocolVersion; - supported: ProtocolVersion; - } - - /** - * This exception indicates an unsupported data encoding version. - */ - class UnsupportedEncodingException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param bad The version of the unsupported encoding. - * @param supported The version of the encoding that is supported. - * @param ice_cause The error that cause this exception. - */ - constructor( - reason?: string, - bad?: EncodingVersion, - supported?: EncodingVersion, - ice_cause?: string | Error, - ); - bad: EncodingVersion; - supported: EncodingVersion; - } - - /** - * This exception indicates that an unknown protocol message has been received. - */ - class UnknownMessageException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if a message is received over a connection that is not yet validated. - */ - class ConnectionNotValidatedException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception indicates that an unknown reply status has been received. - */ - class UnknownReplyStatusException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * 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. - */ - class CloseConnectionException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised by an operation call if the application closes the connection locally using - * {@link Connection#close}. - * @see Connection#close - */ - class ConnectionManuallyClosedException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param graceful True if the connection was closed gracefully, false otherwise. - * @param ice_cause The error that cause this exception. - */ - constructor(graceful?: boolean, ice_cause?: string | Error); - graceful: boolean; - } - - /** - * This exception indicates that a message size is less than the minimum required size. - */ - class IllegalMessageSizeException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception indicates a problem with compressing or uncompressing data. - */ - class CompressionException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised for errors during marshaling or unmarshaling data. - */ - class MarshalException extends ProtocolException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if inconsistent data is received while unmarshaling a proxy. - */ - class ProxyUnmarshalException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if an out-of-bounds condition occurs during unmarshaling. - */ - class UnmarshalOutOfBoundsException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. - * @see ValueFactory - * @see Communicator#getValueFactoryManager - * @see ValueFactoryManager#add - * @see ValueFactoryManager#find - */ - class NoValueFactoryException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param type The Slice type ID of the class instance for which no factory could be found. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, type?: string, ice_cause?: string | Error); - type: string; - } - - /** - * 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. - */ - class UnexpectedObjectException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param type The Slice type ID of the class instance that was unmarshaled. - * @param expectedType The Slice type ID that was expected by the receiving operation. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, type?: string, expectedType?: string, ice_cause?: string | Error); - type: string; - expectedType: string; - } - - /** - * This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the - * Ice.MessageSizeMax property. - */ - class MemoryLimitException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception indicates a malformed data encapsulation. - */ - class EncapsulationException extends MarshalException { - /** - * One-shot constructor to initialize all data members. - * @param reason The reason for the failure. - * @param ice_cause The error that cause this exception. - */ - constructor(reason?: string, ice_cause?: string | Error); - } - - /** - * This exception is raised if an unsupported feature is used. The unsupported feature string contains the name of the - * unsupported feature. - */ - class FeatureNotSupportedException extends LocalException { - /** - * One-shot constructor to initialize all data members. - * @param unsupportedFeature The name of the unsupported feature. - * @param ice_cause The error that cause this exception. - */ - constructor(unsupportedFeature?: string, ice_cause?: string | Error); - unsupportedFeature: string; - } - - /** - * This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. - */ - class FixedProxyException extends LocalException {} + abstract class LocalException extends Exception {} } } diff --git a/js/src/Ice/LocalException.js b/js/src/Ice/LocalException.js index d6ecf1fc74c..9f21af22173 100644 --- a/js/src/Ice/LocalException.js +++ b/js/src/Ice/LocalException.js @@ -1,788 +1,16 @@ // -// Copyright (c) ZeroC, Inc. All rights reserved. +// Ice.LocalException // -import { LocalException } from "./Exception.js"; -import { Ice as Ice_Identity } from "./Identity.js"; -import { Ice as Ice_Version } from "./Version.js"; +import { Exception } from "./Exception.js"; -const Ice = { - ...Ice_Identity, - ...Ice_Version, -}; - -/** - * This exception is raised when a failure occurs during initialization. - **/ -export class InitializationException extends LocalException { - constructor(reason = "", _cause = "") { - super(_cause); - this.reason = reason; - } - - static get _id() { - return "::Ice::InitializationException"; - } -} - -/** - * 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. - **/ -export class AlreadyRegisteredException extends LocalException { - constructor(kindOfObject = "", id = "", _cause = "") { - super(_cause); - this.kindOfObject = kindOfObject; - this.id = id; - } - - static get _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. - **/ -export class NotRegisteredException extends LocalException { - constructor(kindOfObject = "", id = "", _cause = "") { - super(_cause); - this.kindOfObject = kindOfObject; - this.id = id; - } - - static get _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. - **/ -export class TwowayOnlyException extends LocalException { - constructor(operation = "", _cause = "") { - super(_cause); - this.operation = operation; - } - - static get _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. - **/ -export class UnknownException extends LocalException { - constructor(unknown = "", _cause = "") { - super(_cause); - this.unknown = unknown; - } - - static get _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 - * {@link UnknownLocalException}. The only exception to this rule are all exceptions derived from - * {@link RequestFailedException}, which are transmitted by the Ice protocol even though they are declared - * local. - **/ -export class UnknownLocalException extends UnknownException { - constructor(unknown, _cause = "") { - super(unknown, _cause); - } - - static get _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 {@link 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. - **/ -export class UnknownUserException extends UnknownException { - constructor(unknown, _cause = "") { - super(unknown, _cause); - } - - static get _id() { - return "::Ice::UnknownUserException"; - } -} - -/** - * This exception is raised if the {@link Communicator} has been destroyed. - * @see Communicator#destroy - **/ -export class CommunicatorDestroyedException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::CommunicatorDestroyedException"; - } -} - -/** - * This exception is raised if an attempt is made to use a deactivated {@link ObjectAdapter}. - * @see ObjectAdapter#deactivate - * @see Communicator#shutdown - **/ -export class ObjectAdapterDeactivatedException extends LocalException { - constructor(name = "", _cause = "") { - super(_cause); - this.name = name; - } - - static get _id() { - return "::Ice::ObjectAdapterDeactivatedException"; - } -} - -/** - * This exception is raised if an {@link ObjectAdapter} cannot be activated. This happens if the {@link Locator} - * detects another active {@link ObjectAdapter} with the same adapter id. - **/ -export class ObjectAdapterIdInUseException extends LocalException { - constructor(id = "", _cause = "") { - super(_cause); - this.id = id; - } - - static get _id() { - return "::Ice::ObjectAdapterIdInUseException"; - } -} - -/** - * This exception is raised if no suitable endpoint is available. - **/ -export class NoEndpointException extends LocalException { - constructor(proxy = "", _cause = "") { - super(_cause); - this.proxy = proxy; - } - - static get _id() { - return "::Ice::NoEndpointException"; - } -} - -/** - * This exception is raised if there was an error while parsing an endpoint. - **/ -export class EndpointParseException extends LocalException { - constructor(str = "", _cause = "") { - super(_cause); - this.str = str; - } - - static get _id() { - return "::Ice::EndpointParseException"; - } -} - -/** - * This exception is raised if there was an error while parsing an endpoint selection type. - **/ -export class EndpointSelectionTypeParseException extends LocalException { - constructor(str = "", _cause = "") { - super(_cause); - this.str = str; - } - - static get _id() { - return "::Ice::EndpointSelectionTypeParseException"; - } -} - -/** - * This exception is raised if there was an error while parsing a version. - **/ -export class VersionParseException extends LocalException { - constructor(str = "", _cause = "") { - super(_cause); - this.str = str; - } - - static get _id() { - return "::Ice::VersionParseException"; - } -} - -/** - * This exception is raised if there was an error while parsing a stringified identity. - **/ -export class IdentityParseException extends LocalException { - constructor(str = "", _cause = "") { - super(_cause); - this.str = str; - } - - static get _id() { - return "::Ice::IdentityParseException"; - } -} - -/** - * This exception is raised if there was an error while parsing a stringified proxy. - **/ -export class ProxyParseException extends LocalException { - constructor(str = "", _cause = "") { - super(_cause); - this.str = str; - } - - static get _id() { - return "::Ice::ProxyParseException"; - } -} - -/** - * This exception is raised if an illegal identity is encountered. - **/ -export class IllegalIdentityException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::IllegalIdentityException"; - } -} - -/** - * This exception is raised to reject an illegal servant (typically a null servant). - **/ -export class IllegalServantException extends LocalException { - constructor(reason = "", _cause = "") { - super(_cause); - this.reason = reason; - } - - static get _id() { - return "::Ice::IllegalServantException"; - } -} - -/** - * This exception is raised if a request failed. This exception, and all exceptions derived from - * {@link RequestFailedException}, are transmitted by the Ice protocol, even though they are declared - * local. - **/ -export class RequestFailedException extends LocalException { - constructor(id = new Ice.Identity(), facet = "", operation = "", _cause = "") { - super(_cause); - this.id = id; - this.facet = facet; - this.operation = operation; - } - - static get _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. - **/ -export class ObjectNotExistException extends RequestFailedException { - constructor(id, facet, operation, _cause = "") { - super(id, facet, operation, _cause); - } - - static get _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. - **/ -export class FacetNotExistException extends RequestFailedException { - constructor(id, facet, operation, _cause = "") { - super(id, facet, operation, _cause); - } - - static get _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. - **/ -export class OperationNotExistException extends RequestFailedException { - constructor(id, facet, operation, _cause = "") { - super(id, facet, operation, _cause); - } - - static get _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, {@link SyscallException#error} should be inspected. - **/ -export class SyscallException extends LocalException { - constructor(error = 0, _cause = "") { - super(_cause); - this.error = error; - } - - static get _id() { - return "::Ice::SyscallException"; - } -} - -/** - * This exception indicates socket errors. - **/ -export class SocketException extends SyscallException { - constructor(error, _cause = "") { - super(error, _cause); - } - - static get _id() { - return "::Ice::SocketException"; - } -} - -/** - * This exception indicates connection failures. - **/ -export class ConnectFailedException extends SocketException { - constructor(error, _cause = "") { - super(error, _cause); - } - - static get _id() { - return "::Ice::ConnectFailedException"; - } -} - -/** - * This exception indicates a connection failure for which the server host actively refuses a connection. - **/ -export class ConnectionRefusedException extends ConnectFailedException { - constructor(error, _cause = "") { - super(error, _cause); - } - - static get _id() { - return "::Ice::ConnectionRefusedException"; - } -} - -/** - * This exception indicates a lost connection. - **/ -export class ConnectionLostException extends SocketException { - constructor(error, _cause = "") { - super(error, _cause); - } - - static get _id() { - return "::Ice::ConnectionLostException"; - } -} - -/** - * This exception indicates a timeout condition. - **/ -export class TimeoutException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::TimeoutException"; - } -} - -/** - * This exception indicates a connection establishment timeout condition. - **/ -export class ConnectTimeoutException extends TimeoutException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::ConnectTimeoutException"; - } -} - -/** - * This exception indicates a connection closure timeout condition. - **/ -export class CloseTimeoutException extends TimeoutException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::CloseTimeoutException"; - } -} - -/** - * This exception indicates that a connection was closed gracefully. - **/ -export class ConnectionClosedException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::ConnectionClosedException"; - } -} - -/** - * This exception indicates that a connection was aborted by the idle check. - **/ -export class ConnectionIdleException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::ConnectionIdleException"; - } -} - -/** - * This exception indicates that an invocation failed because it timed out. - **/ -export class InvocationTimeoutException extends TimeoutException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::InvocationTimeoutException"; - } -} - -/** - * This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. - **/ -export class InvocationCanceledException extends LocalException { - constructor(_cause = "") { - super(_cause); - } - - static get _id() { - return "::Ice::InvocationCanceledException"; - } -} - -/** - * A generic exception base for all kinds of protocol error conditions. - **/ -export class ProtocolException extends LocalException { - constructor(reason = "", _cause = "") { - super(_cause); - this.reason = reason; - } - - static get _id() { - return "::Ice::ProtocolException"; - } -} - -/** - * This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). - **/ -export class BadMagicException extends ProtocolException { - constructor(reason, badMagic = null, _cause = "") { - super(reason, _cause); - this.badMagic = badMagic; - } - - static get _id() { - return "::Ice::BadMagicException"; - } -} - -/** - * This exception indicates an unsupported protocol version. - **/ -export class UnsupportedProtocolException extends ProtocolException { - constructor(reason, bad = new Ice.ProtocolVersion(), supported = new Ice.ProtocolVersion(), _cause = "") { - super(reason, _cause); - this.bad = bad; - this.supported = supported; - } - - static get _id() { - return "::Ice::UnsupportedProtocolException"; - } -} - -/** - * This exception indicates an unsupported data encoding version. - **/ -export class UnsupportedEncodingException extends ProtocolException { - constructor(reason, bad = new Ice.EncodingVersion(), supported = new Ice.EncodingVersion(), _cause = "") { - super(reason, _cause); - this.bad = bad; - this.supported = supported; - } - - static get _id() { - return "::Ice::UnsupportedEncodingException"; - } -} - -/** - * This exception indicates that an unknown protocol message has been received. - **/ -export class UnknownMessageException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::UnknownMessageException"; - } -} - -/** - * This exception is raised if a message is received over a connection that is not yet validated. - **/ -export class ConnectionNotValidatedException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::ConnectionNotValidatedException"; - } -} - -/** - * This exception indicates that an unknown reply status has been received. - **/ -export class UnknownReplyStatusException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _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. - **/ -export class CloseConnectionException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::CloseConnectionException"; - } -} - -/** - * This exception is raised by an operation call if the application closes the connection locally using - * {@link Connection#close}. - * @see Connection#close - **/ -export class ConnectionManuallyClosedException extends LocalException { - constructor(graceful = false, _cause = "") { - super(_cause); - this.graceful = graceful; - } - - static get _id() { - return "::Ice::ConnectionManuallyClosedException"; - } -} - -/** - * This exception indicates that a message size is less than the minimum required size. - **/ -export class IllegalMessageSizeException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::IllegalMessageSizeException"; - } -} - -/** - * This exception indicates a problem with compressing or uncompressing data. - **/ -export class CompressionException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::CompressionException"; - } -} - -/** - * This exception is raised for errors during marshaling or unmarshaling data. - **/ -export class MarshalException extends ProtocolException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::MarshalException"; - } -} - -/** - * This exception is raised if inconsistent data is received while unmarshaling a proxy. - **/ -export class ProxyUnmarshalException extends MarshalException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::ProxyUnmarshalException"; - } -} - -/** - * This exception is raised if an out-of-bounds condition occurs during unmarshaling. - **/ -export class UnmarshalOutOfBoundsException extends MarshalException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::UnmarshalOutOfBoundsException"; - } -} - -/** - * This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. - * @see ValueFactory - * @see Communicator#getValueFactoryManager - * @see ValueFactoryManager#add - * @see ValueFactoryManager#find - **/ -export class NoValueFactoryException extends MarshalException { - constructor(reason, type = "", _cause = "") { - super(reason, _cause); - this.type = type; - } - - static get _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. - **/ -export class UnexpectedObjectException extends MarshalException { - constructor(reason, type = "", expectedType = "", _cause = "") { - super(reason, _cause); - this.type = type; - this.expectedType = expectedType; - } - - static get _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. - **/ -export class MemoryLimitException extends MarshalException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _id() { - return "::Ice::MemoryLimitException"; - } -} - -/** - * This exception indicates a malformed data encapsulation. - **/ -export class EncapsulationException extends MarshalException { - constructor(reason, _cause = "") { - super(reason, _cause); - } - - static get _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. - **/ -export class FeatureNotSupportedException extends LocalException { - constructor(unsupportedFeature = "", _cause = "") { - super(_cause); - this.unsupportedFeature = unsupportedFeature; - } - - static get _id() { - return "::Ice::FeatureNotSupportedException"; - } -} - -/** - * This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. - **/ -export class FixedProxyException extends LocalException { - constructor(_cause = "") { - super(_cause); +export class LocalException extends Exception { + constructor(cause) { + super(cause); + Exception.captureStackTrace(this); } static get _id() { - return "::Ice::FixedProxyException"; + return "::Ice::LocalException"; } } diff --git a/js/src/Ice/LocalExceptions.d.ts b/js/src/Ice/LocalExceptions.d.ts new file mode 100644 index 00000000000..38233a9db13 --- /dev/null +++ b/js/src/Ice/LocalExceptions.d.ts @@ -0,0 +1,687 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +declare module "ice" { + namespace Ice { + /** + * This exception is raised when a failure occurs during initialization. + */ + class InitializationException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + reason: string; + } + + /** + * 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. + */ + class AlreadyRegisteredException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param kindOfObject The kind of object that could not be removed: "servant", "facet", "object", "default servant", "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". + * @param id The ID (or name) of the object that is registered already. + * @param ice_cause The error that cause this exception. + */ + constructor(kindOfObject?: string, id?: string, ice_cause?: string | Error); + kindOfObject: string; + id: string; + } + + /** + * 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. + */ + class NotRegisteredException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param kindOfObject The kind of object that could not be removed: "servant", "facet", "object", "default servant", "servant locator", "value factory", "plugin", "object adapter", "object adapter with router", "replica group". + * @param id The ID (or name) of the object that could not be removed. + * @param ice_cause The error that cause this exception. + */ + constructor(kindOfObject?: string, id?: string, ice_cause?: string | Error); + kindOfObject: string; + id: string; + } + + /** + * 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. + */ + class TwowayOnlyException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param operation The name of the operation that was invoked. + * @param ice_cause The error that cause this exception. + */ + constructor(operation?: string, ice_cause?: string | Error); + operation: string; + } + + /** + * 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. + */ + class UnknownException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param unknown This field is set to the textual representation of the unknown exception if available. + * @param ice_cause The error that cause this exception. + */ + constructor(unknown?: string, ice_cause?: string | Error); + unknown: string; + } + + /** + * 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 + * {@link UnknownLocalException}. The only exception to this rule are all exceptions derived from + * {@link RequestFailedException}, which are transmitted by the Ice protocol even though they are declared + * local. + */ + class UnknownLocalException extends UnknownException { + /** + * One-shot constructor to initialize all data members. + * @param unknown This field is set to the textual representation of the unknown exception if available. + * @param ice_cause The error that cause this exception. + */ + constructor(unknown?: string, ice_cause?: string | Error); + } + + /** + * 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 {@link 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. + */ + class UnknownUserException extends UnknownException { + /** + * One-shot constructor to initialize all data members. + * @param unknown This field is set to the textual representation of the unknown exception if available. + * @param ice_cause The error that cause this exception. + */ + constructor(unknown?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if the {@link Communicator} has been destroyed. + * @see Communicator#destroy + */ + class CommunicatorDestroyedException extends LocalException {} + + /** + * This exception is raised if an attempt is made to use a deactivated {@link ObjectAdapter}. + * @see ObjectAdapter#deactivate + * @see Communicator#shutdown + */ + class ObjectAdapterDeactivatedException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param name Name of the adapter. + * @param ice_cause The error that cause this exception. + */ + constructor(name?: string, ice_cause?: string | Error); + name: string; + } + + /** + * This exception is raised if an {@link ObjectAdapter} cannot be activated. This happens if the {@link Locator} + * detects another active {@link ObjectAdapter} with the same adapter id. + */ + class ObjectAdapterIdInUseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param id Adapter ID. + * @param ice_cause The error that cause this exception. + */ + constructor(id?: string, ice_cause?: string | Error); + id: string; + } + + /** + * This exception is raised if no suitable endpoint is available. + */ + class NoEndpointException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param proxy The stringified proxy for which no suitable endpoint is available. + * @param ice_cause The error that cause this exception. + */ + constructor(proxy?: string, ice_cause?: string | Error); + proxy: string; + } + + /** + * This exception is raised if there was an error while parsing an endpoint. + */ + class EndpointParseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param str Describes the failure and includes the string that could not be parsed. + * @param ice_cause The error that cause this exception. + */ + constructor(str?: string, ice_cause?: string | Error); + str: string; + } + + /** + * This exception is raised if there was an error while parsing an endpoint selection type. + */ + class EndpointSelectionTypeParseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param str Describes the failure and includes the string that could not be parsed. + * @param ice_cause The error that cause this exception. + */ + constructor(str?: string, ice_cause?: string | Error); + str: string; + } + + /** + * This exception is raised if there was an error while parsing a version. + */ + class VersionParseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param str Describes the failure and includes the string that could not be parsed. + * @param ice_cause The error that cause this exception. + */ + constructor(str?: string, ice_cause?: string | Error); + str: string; + } + + /** + * This exception is raised if there was an error while parsing a stringified identity. + */ + class IdentityParseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param str Describes the failure and includes the string that could not be parsed. + * @param ice_cause The error that cause this exception. + */ + constructor(str?: string, ice_cause?: string | Error); + str: string; + } + + /** + * This exception is raised if there was an error while parsing a stringified proxy. + */ + class ProxyParseException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param str Describes the failure and includes the string that could not be parsed. + * @param ice_cause The error that cause this exception. + */ + constructor(str?: string, ice_cause?: string | Error); + str: string; + } + + /** + * This exception is raised if an identity with an empty name is encountered. + */ + class IllegalIdentityException extends LocalException {} + + /** + * This exception is raised to reject an illegal servant (typically a null servant). + */ + class IllegalServantException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param reason Describes why this servant is illegal. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + reason: string; + } + + /** + * This exception is raised if a request failed. This exception, and all exceptions derived from + * {@link RequestFailedException}, are transmitted by the Ice protocol, even though they are declared + * local. + */ + class RequestFailedException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param id The identity of the Ice Object to which the request was sent. + * @param facet The facet to which the request was sent. + * @param operation The operation name of the request. + * @param ice_cause The error that cause this exception. + */ + constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); + id: Identity; + facet: string; + operation: string; + } + + /** + * This exception is raised if an object does not exist on the server, that is, if no facets with the given identity + * exist. + */ + class ObjectNotExistException extends RequestFailedException { + /** + * One-shot constructor to initialize all data members. + * @param id The identity of the Ice Object to which the request was sent. + * @param facet The facet to which the request was sent. + * @param operation The operation name of the request. + * @param ice_cause The error that cause this exception. + */ + constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if no facet with the given name exists, but at least one facet with the given identity + * exists. + */ + class FacetNotExistException extends RequestFailedException { + /** + * One-shot constructor to initialize all data members. + * @param id The identity of the Ice Object to which the request was sent. + * @param facet The facet to which the request was sent. + * @param operation The operation name of the request. + * @param ice_cause The error that cause this exception. + */ + constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); + } + + /** + * 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. + */ + class OperationNotExistException extends RequestFailedException { + /** + * One-shot constructor to initialize all data members. + * @param id The identity of the Ice Object to which the request was sent. + * @param facet The facet to which the request was sent. + * @param operation The operation name of the request. + * @param ice_cause The error that cause this exception. + */ + constructor(id?: Identity, facet?: string, operation?: string, ice_cause?: string | Error); + } + + /** + * 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, {@link SyscallException#error} should be inspected. + */ + class SyscallException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param error The error number describing the system exception. + * @param ice_cause The error that cause this exception. + */ + constructor(error?: number, ice_cause?: string | Error); + error: number; + } + + /** + * This exception indicates socket errors. + */ + class SocketException extends SyscallException { + /** + * One-shot constructor to initialize all data members. + * @param error The error number describing the system exception. + * @param ice_cause The error that cause this exception. + */ + constructor(error?: number, ice_cause?: string | Error); + } + + /** + * This exception indicates connection failures. + */ + class ConnectFailedException extends SocketException { + /** + * One-shot constructor to initialize all data members. + * @param error The error number describing the system exception. + * @param ice_cause The error that cause this exception. + */ + constructor(error?: number, ice_cause?: string | Error); + } + + /** + * This exception indicates a connection failure for which the server host actively refuses a connection. + */ + class ConnectionRefusedException extends ConnectFailedException { + /** + * One-shot constructor to initialize all data members. + * @param error The error number describing the system exception. + * @param ice_cause The error that cause this exception. + */ + constructor(error?: number, ice_cause?: string | Error); + } + + /** + * This exception indicates a lost connection. + */ + class ConnectionLostException extends SocketException { + /** + * One-shot constructor to initialize all data members. + * @param error The error number describing the system exception. + * @param ice_cause The error that cause this exception. + */ + constructor(error?: number, ice_cause?: string | Error); + } + + /** + * This exception indicates a timeout condition. + */ + class TimeoutException extends LocalException {} + + /** + * This exception indicates a connection establishment timeout condition. + */ + class ConnectTimeoutException extends TimeoutException {} + + /** + * This exception indicates a connection closure timeout condition. + */ + class CloseTimeoutException extends TimeoutException {} + + /** + * This exception indicates that a connection was closed gracefully. + */ + class ConnectionClosedException extends LocalException {} + + /** + * This exception indicates that a connection was aborted by the idle check. + */ + class ConnectionIdleException extends LocalException {} + + /** + * This exception indicates that an invocation failed because it timed out. + */ + class InvocationTimeoutException extends TimeoutException {} + + /** + * This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. + */ + class InvocationCanceledException extends LocalException {} + + /** + * A generic exception base for all kinds of protocol error conditions. + */ + class ProtocolException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + reason: string; + } + + /** + * This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). + */ + class BadMagicException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param badMagic A sequence containing the first four bytes of the incorrect message. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, badMagic?: ByteSeq, ice_cause?: string | Error); + badMagic: ByteSeq; + } + + /** + * This exception indicates an unsupported protocol version. + */ + class UnsupportedProtocolException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param bad The version of the unsupported protocol. + * @param supported The version of the protocol that is supported. + * @param ice_cause The error that cause this exception. + */ + constructor( + reason?: string, + bad?: ProtocolVersion, + supported?: ProtocolVersion, + ice_cause?: string | Error, + ); + bad: ProtocolVersion; + supported: ProtocolVersion; + } + + /** + * This exception indicates an unsupported data encoding version. + */ + class UnsupportedEncodingException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param bad The version of the unsupported encoding. + * @param supported The version of the encoding that is supported. + * @param ice_cause The error that cause this exception. + */ + constructor( + reason?: string, + bad?: EncodingVersion, + supported?: EncodingVersion, + ice_cause?: string | Error, + ); + bad: EncodingVersion; + supported: EncodingVersion; + } + + /** + * This exception indicates that an unknown protocol message has been received. + */ + class UnknownMessageException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if a message is received over a connection that is not yet validated. + */ + class ConnectionNotValidatedException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception indicates that an unknown reply status has been received. + */ + class UnknownReplyStatusException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * 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. + */ + class CloseConnectionException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised by an operation call if the application closes the connection locally using + * {@link Connection#close}. + * @see Connection#close + */ + class ConnectionManuallyClosedException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param graceful True if the connection was closed gracefully, false otherwise. + * @param ice_cause The error that cause this exception. + */ + constructor(graceful?: boolean, ice_cause?: string | Error); + graceful: boolean; + } + + /** + * This exception indicates that a message size is less than the minimum required size. + */ + class IllegalMessageSizeException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception indicates a problem with compressing or uncompressing data. + */ + class CompressionException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised for errors during marshaling or unmarshaling data. + */ + class MarshalException extends ProtocolException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if inconsistent data is received while unmarshaling a proxy. + */ + class ProxyUnmarshalException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if an out-of-bounds condition occurs during unmarshaling. + */ + class UnmarshalOutOfBoundsException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. + * @see ValueFactory + * @see Communicator#getValueFactoryManager + * @see ValueFactoryManager#add + * @see ValueFactoryManager#find + */ + class NoValueFactoryException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param type The Slice type ID of the class instance for which no factory could be found. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, type?: string, ice_cause?: string | Error); + type: string; + } + + /** + * 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. + */ + class UnexpectedObjectException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param type The Slice type ID of the class instance that was unmarshaled. + * @param expectedType The Slice type ID that was expected by the receiving operation. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, type?: string, expectedType?: string, ice_cause?: string | Error); + type: string; + expectedType: string; + } + + /** + * This exception is raised when Ice receives a request or reply message whose size exceeds the limit specified by the + * Ice.MessageSizeMax property. + */ + class MemoryLimitException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception indicates a malformed data encapsulation. + */ + class EncapsulationException extends MarshalException { + /** + * One-shot constructor to initialize all data members. + * @param reason The reason for the failure. + * @param ice_cause The error that cause this exception. + */ + constructor(reason?: string, ice_cause?: string | Error); + } + + /** + * This exception is raised if an unsupported feature is used. The unsupported feature string contains the name of the + * unsupported feature. + */ + class FeatureNotSupportedException extends LocalException { + /** + * One-shot constructor to initialize all data members. + * @param unsupportedFeature The name of the unsupported feature. + * @param ice_cause The error that cause this exception. + */ + constructor(unsupportedFeature?: string, ice_cause?: string | Error); + unsupportedFeature: string; + } + + /** + * This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. + */ + class FixedProxyException extends LocalException {} + } +} diff --git a/js/src/Ice/LocalExceptions.js b/js/src/Ice/LocalExceptions.js new file mode 100644 index 00000000000..0db867fb67c --- /dev/null +++ b/js/src/Ice/LocalExceptions.js @@ -0,0 +1,788 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +import { LocalException } from "./LocalException.js"; +import { Ice as Ice_Identity } from "./Identity.js"; +import { Ice as Ice_Version } from "./Version.js"; + +const Ice = { + ...Ice_Identity, + ...Ice_Version, +}; + +/** + * This exception is raised when a failure occurs during initialization. + **/ +export class InitializationException extends LocalException { + constructor(reason = "", _cause = "") { + super(_cause); + this.reason = reason; + } + + static get _id() { + return "::Ice::InitializationException"; + } +} + +/** + * 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. + **/ +export class AlreadyRegisteredException extends LocalException { + constructor(kindOfObject = "", id = "", _cause = "") { + super(_cause); + this.kindOfObject = kindOfObject; + this.id = id; + } + + static get _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. + **/ +export class NotRegisteredException extends LocalException { + constructor(kindOfObject = "", id = "", _cause = "") { + super(_cause); + this.kindOfObject = kindOfObject; + this.id = id; + } + + static get _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. + **/ +export class TwowayOnlyException extends LocalException { + constructor(operation = "", _cause = "") { + super(_cause); + this.operation = operation; + } + + static get _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. + **/ +export class UnknownException extends LocalException { + constructor(unknown = "", _cause = "") { + super(_cause); + this.unknown = unknown; + } + + static get _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 + * {@link UnknownLocalException}. The only exception to this rule are all exceptions derived from + * {@link RequestFailedException}, which are transmitted by the Ice protocol even though they are declared + * local. + **/ +export class UnknownLocalException extends UnknownException { + constructor(unknown, _cause = "") { + super(unknown, _cause); + } + + static get _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 {@link 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. + **/ +export class UnknownUserException extends UnknownException { + constructor(unknown, _cause = "") { + super(unknown, _cause); + } + + static get _id() { + return "::Ice::UnknownUserException"; + } +} + +/** + * This exception is raised if the {@link Communicator} has been destroyed. + * @see Communicator#destroy + **/ +export class CommunicatorDestroyedException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::CommunicatorDestroyedException"; + } +} + +/** + * This exception is raised if an attempt is made to use a deactivated {@link ObjectAdapter}. + * @see ObjectAdapter#deactivate + * @see Communicator#shutdown + **/ +export class ObjectAdapterDeactivatedException extends LocalException { + constructor(name = "", _cause = "") { + super(_cause); + this.name = name; + } + + static get _id() { + return "::Ice::ObjectAdapterDeactivatedException"; + } +} + +/** + * This exception is raised if an {@link ObjectAdapter} cannot be activated. This happens if the {@link Locator} + * detects another active {@link ObjectAdapter} with the same adapter id. + **/ +export class ObjectAdapterIdInUseException extends LocalException { + constructor(id = "", _cause = "") { + super(_cause); + this.id = id; + } + + static get _id() { + return "::Ice::ObjectAdapterIdInUseException"; + } +} + +/** + * This exception is raised if no suitable endpoint is available. + **/ +export class NoEndpointException extends LocalException { + constructor(proxy = "", _cause = "") { + super(_cause); + this.proxy = proxy; + } + + static get _id() { + return "::Ice::NoEndpointException"; + } +} + +/** + * This exception is raised if there was an error while parsing an endpoint. + **/ +export class EndpointParseException extends LocalException { + constructor(str = "", _cause = "") { + super(_cause); + this.str = str; + } + + static get _id() { + return "::Ice::EndpointParseException"; + } +} + +/** + * This exception is raised if there was an error while parsing an endpoint selection type. + **/ +export class EndpointSelectionTypeParseException extends LocalException { + constructor(str = "", _cause = "") { + super(_cause); + this.str = str; + } + + static get _id() { + return "::Ice::EndpointSelectionTypeParseException"; + } +} + +/** + * This exception is raised if there was an error while parsing a version. + **/ +export class VersionParseException extends LocalException { + constructor(str = "", _cause = "") { + super(_cause); + this.str = str; + } + + static get _id() { + return "::Ice::VersionParseException"; + } +} + +/** + * This exception is raised if there was an error while parsing a stringified identity. + **/ +export class IdentityParseException extends LocalException { + constructor(str = "", _cause = "") { + super(_cause); + this.str = str; + } + + static get _id() { + return "::Ice::IdentityParseException"; + } +} + +/** + * This exception is raised if there was an error while parsing a stringified proxy. + **/ +export class ProxyParseException extends LocalException { + constructor(str = "", _cause = "") { + super(_cause); + this.str = str; + } + + static get _id() { + return "::Ice::ProxyParseException"; + } +} + +/** + * This exception is raised if an illegal identity is encountered. + **/ +export class IllegalIdentityException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::IllegalIdentityException"; + } +} + +/** + * This exception is raised to reject an illegal servant (typically a null servant). + **/ +export class IllegalServantException extends LocalException { + constructor(reason = "", _cause = "") { + super(_cause); + this.reason = reason; + } + + static get _id() { + return "::Ice::IllegalServantException"; + } +} + +/** + * This exception is raised if a request failed. This exception, and all exceptions derived from + * {@link RequestFailedException}, are transmitted by the Ice protocol, even though they are declared + * local. + **/ +export class RequestFailedException extends LocalException { + constructor(id = new Ice.Identity(), facet = "", operation = "", _cause = "") { + super(_cause); + this.id = id; + this.facet = facet; + this.operation = operation; + } + + static get _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. + **/ +export class ObjectNotExistException extends RequestFailedException { + constructor(id, facet, operation, _cause = "") { + super(id, facet, operation, _cause); + } + + static get _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. + **/ +export class FacetNotExistException extends RequestFailedException { + constructor(id, facet, operation, _cause = "") { + super(id, facet, operation, _cause); + } + + static get _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. + **/ +export class OperationNotExistException extends RequestFailedException { + constructor(id, facet, operation, _cause = "") { + super(id, facet, operation, _cause); + } + + static get _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, {@link SyscallException#error} should be inspected. + **/ +export class SyscallException extends LocalException { + constructor(error = 0, _cause = "") { + super(_cause); + this.error = error; + } + + static get _id() { + return "::Ice::SyscallException"; + } +} + +/** + * This exception indicates socket errors. + **/ +export class SocketException extends SyscallException { + constructor(error, _cause = "") { + super(error, _cause); + } + + static get _id() { + return "::Ice::SocketException"; + } +} + +/** + * This exception indicates connection failures. + **/ +export class ConnectFailedException extends SocketException { + constructor(error, _cause = "") { + super(error, _cause); + } + + static get _id() { + return "::Ice::ConnectFailedException"; + } +} + +/** + * This exception indicates a connection failure for which the server host actively refuses a connection. + **/ +export class ConnectionRefusedException extends ConnectFailedException { + constructor(error, _cause = "") { + super(error, _cause); + } + + static get _id() { + return "::Ice::ConnectionRefusedException"; + } +} + +/** + * This exception indicates a lost connection. + **/ +export class ConnectionLostException extends SocketException { + constructor(error, _cause = "") { + super(error, _cause); + } + + static get _id() { + return "::Ice::ConnectionLostException"; + } +} + +/** + * This exception indicates a timeout condition. + **/ +export class TimeoutException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::TimeoutException"; + } +} + +/** + * This exception indicates a connection establishment timeout condition. + **/ +export class ConnectTimeoutException extends TimeoutException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::ConnectTimeoutException"; + } +} + +/** + * This exception indicates a connection closure timeout condition. + **/ +export class CloseTimeoutException extends TimeoutException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::CloseTimeoutException"; + } +} + +/** + * This exception indicates that a connection was closed gracefully. + **/ +export class ConnectionClosedException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::ConnectionClosedException"; + } +} + +/** + * This exception indicates that a connection was aborted by the idle check. + **/ +export class ConnectionIdleException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::ConnectionIdleException"; + } +} + +/** + * This exception indicates that an invocation failed because it timed out. + **/ +export class InvocationTimeoutException extends TimeoutException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::InvocationTimeoutException"; + } +} + +/** + * This exception indicates that an asynchronous invocation failed because it was canceled explicitly by the user. + **/ +export class InvocationCanceledException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::InvocationCanceledException"; + } +} + +/** + * A generic exception base for all kinds of protocol error conditions. + **/ +export class ProtocolException extends LocalException { + constructor(reason = "", _cause = "") { + super(_cause); + this.reason = reason; + } + + static get _id() { + return "::Ice::ProtocolException"; + } +} + +/** + * This exception indicates that a message did not start with the expected magic number ('I', 'c', 'e', 'P'). + **/ +export class BadMagicException extends ProtocolException { + constructor(reason, badMagic = null, _cause = "") { + super(reason, _cause); + this.badMagic = badMagic; + } + + static get _id() { + return "::Ice::BadMagicException"; + } +} + +/** + * This exception indicates an unsupported protocol version. + **/ +export class UnsupportedProtocolException extends ProtocolException { + constructor(reason, bad = new Ice.ProtocolVersion(), supported = new Ice.ProtocolVersion(), _cause = "") { + super(reason, _cause); + this.bad = bad; + this.supported = supported; + } + + static get _id() { + return "::Ice::UnsupportedProtocolException"; + } +} + +/** + * This exception indicates an unsupported data encoding version. + **/ +export class UnsupportedEncodingException extends ProtocolException { + constructor(reason, bad = new Ice.EncodingVersion(), supported = new Ice.EncodingVersion(), _cause = "") { + super(reason, _cause); + this.bad = bad; + this.supported = supported; + } + + static get _id() { + return "::Ice::UnsupportedEncodingException"; + } +} + +/** + * This exception indicates that an unknown protocol message has been received. + **/ +export class UnknownMessageException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::UnknownMessageException"; + } +} + +/** + * This exception is raised if a message is received over a connection that is not yet validated. + **/ +export class ConnectionNotValidatedException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::ConnectionNotValidatedException"; + } +} + +/** + * This exception indicates that an unknown reply status has been received. + **/ +export class UnknownReplyStatusException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _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. + **/ +export class CloseConnectionException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::CloseConnectionException"; + } +} + +/** + * This exception is raised by an operation call if the application closes the connection locally using + * {@link Connection#close}. + * @see Connection#close + **/ +export class ConnectionManuallyClosedException extends LocalException { + constructor(graceful = false, _cause = "") { + super(_cause); + this.graceful = graceful; + } + + static get _id() { + return "::Ice::ConnectionManuallyClosedException"; + } +} + +/** + * This exception indicates that a message size is less than the minimum required size. + **/ +export class IllegalMessageSizeException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::IllegalMessageSizeException"; + } +} + +/** + * This exception indicates a problem with compressing or uncompressing data. + **/ +export class CompressionException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::CompressionException"; + } +} + +/** + * This exception is raised for errors during marshaling or unmarshaling data. + **/ +export class MarshalException extends ProtocolException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::MarshalException"; + } +} + +/** + * This exception is raised if inconsistent data is received while unmarshaling a proxy. + **/ +export class ProxyUnmarshalException extends MarshalException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::ProxyUnmarshalException"; + } +} + +/** + * This exception is raised if an out-of-bounds condition occurs during unmarshaling. + **/ +export class UnmarshalOutOfBoundsException extends MarshalException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::UnmarshalOutOfBoundsException"; + } +} + +/** + * This exception is raised if no suitable value factory was found during unmarshaling of a Slice class instance. + * @see ValueFactory + * @see Communicator#getValueFactoryManager + * @see ValueFactoryManager#add + * @see ValueFactoryManager#find + **/ +export class NoValueFactoryException extends MarshalException { + constructor(reason, type = "", _cause = "") { + super(reason, _cause); + this.type = type; + } + + static get _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. + **/ +export class UnexpectedObjectException extends MarshalException { + constructor(reason, type = "", expectedType = "", _cause = "") { + super(reason, _cause); + this.type = type; + this.expectedType = expectedType; + } + + static get _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. + **/ +export class MemoryLimitException extends MarshalException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _id() { + return "::Ice::MemoryLimitException"; + } +} + +/** + * This exception indicates a malformed data encapsulation. + **/ +export class EncapsulationException extends MarshalException { + constructor(reason, _cause = "") { + super(reason, _cause); + } + + static get _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. + **/ +export class FeatureNotSupportedException extends LocalException { + constructor(unsupportedFeature = "", _cause = "") { + super(_cause); + this.unsupportedFeature = unsupportedFeature; + } + + static get _id() { + return "::Ice::FeatureNotSupportedException"; + } +} + +/** + * This exception indicates that an attempt has been made to change the connection properties of a fixed proxy. + **/ +export class FixedProxyException extends LocalException { + constructor(_cause = "") { + super(_cause); + } + + static get _id() { + return "::Ice::FixedProxyException"; + } +} diff --git a/js/src/Ice/LocatorInfo.js b/js/src/Ice/LocatorInfo.js index 254b5de2a1a..ce310fa1288 100644 --- a/js/src/Ice/LocatorInfo.js +++ b/js/src/Ice/LocatorInfo.js @@ -9,8 +9,9 @@ import { Protocol } from "./Protocol.js"; import { EndpointSelectionType } from "./EndpointSelectionType.js"; import { Promise } from "./Promise.js"; import { identityToString } from "./IdentityUtil.js"; -import { LocalException, UserException } from "./Exception.js"; -import { NotRegisteredException } from "./LocalException.js"; +import { LocalException } from "./LocalException.js"; +import { UserException } from "./UserException.js"; +import { NotRegisteredException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; export class LocatorInfo { diff --git a/js/src/Ice/ObjectAdapter.js b/js/src/Ice/ObjectAdapter.js index 00bd54a5346..06bd7818dde 100644 --- a/js/src/Ice/ObjectAdapter.js +++ b/js/src/Ice/ObjectAdapter.js @@ -15,7 +15,7 @@ import { IllegalIdentityException, ObjectAdapterDeactivatedException, ProxyParseException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { Ice as Ice_Router } from "./Router.js"; const { RouterPrx } = Ice_Router; import { Promise } from "./Promise.js"; diff --git a/js/src/Ice/ObjectAdapterFactory.js b/js/src/Ice/ObjectAdapterFactory.js index 4f8c3ca365f..7a2abec0323 100644 --- a/js/src/Ice/ObjectAdapterFactory.js +++ b/js/src/Ice/ObjectAdapterFactory.js @@ -4,7 +4,7 @@ import { ObjectAdapter } from "./ObjectAdapter.js"; import { Promise } from "./Promise.js"; -import { ObjectAdapterDeactivatedException, AlreadyRegisteredException } from "./LocalException.js"; +import { ObjectAdapterDeactivatedException, AlreadyRegisteredException } from "./LocalExceptions.js"; import { generateUUID } from "./UUID.js"; // diff --git a/js/src/Ice/ObjectPrxExtensions.js b/js/src/Ice/ObjectPrxExtensions.js index c87643097c7..a8b3c257db3 100644 --- a/js/src/Ice/ObjectPrxExtensions.js +++ b/js/src/Ice/ObjectPrxExtensions.js @@ -8,13 +8,8 @@ import { ArrayUtil } from "./ArrayUtil.js"; import { AsyncResultBase } from "./AsyncResultBase.js"; import { OutgoingAsync, ProxyFlushBatch, ProxyGetConnection } from "./OutgoingAsync.js"; import { ReferenceMode } from "./ReferenceMode.js"; -import { UserException } from "./Exception.js"; -import { - FacetNotExistException, - IllegalIdentityException, - TwowayOnlyException, - UnknownUserException, -} from "./LocalException.js"; +import { UserException } from "./UserException.js"; +import { IllegalIdentityException, TwowayOnlyException, UnknownUserException } from "./LocalExceptions.js"; import { ConnectionI } from "./ConnectionI.js"; import { TypeRegistry } from "./TypeRegistry.js"; import { Debug } from "./Debug.js"; diff --git a/js/src/Ice/OpaqueEndpoint.js b/js/src/Ice/OpaqueEndpoint.js index 228ebaa081b..34d86912559 100644 --- a/js/src/Ice/OpaqueEndpoint.js +++ b/js/src/Ice/OpaqueEndpoint.js @@ -3,7 +3,7 @@ // import { Base64 } from "./Base64.js"; -import { EndpointParseException } from "./LocalException.js"; +import { EndpointParseException } from "./LocalExceptions.js"; import { HashUtil } from "./HashUtil.js"; import { StringUtil } from "./StringUtil.js"; import { EndpointI } from "./EndpointI.js"; diff --git a/js/src/Ice/Operation.js b/js/src/Ice/Operation.js index 30a85773bb5..e663ac0182d 100644 --- a/js/src/Ice/Operation.js +++ b/js/src/Ice/Operation.js @@ -5,7 +5,7 @@ import { Ice as Ice_OperationMode } from "./OperationMode.js"; const { OperationMode } = Ice_OperationMode; import { FormatType } from "./FormatType.js"; -import { UnknownException, MarshalException, OperationNotExistException } from "./LocalException.js"; +import { UnknownException, MarshalException, OperationNotExistException } from "./LocalExceptions.js"; import { ObjectPrx } from "./ObjectPrx.js"; import { TypeRegistry } from "./TypeRegistry.js"; diff --git a/js/src/Ice/OutgoingAsync.js b/js/src/Ice/OutgoingAsync.js index 815de0027be..cdbbc9a9466 100644 --- a/js/src/Ice/OutgoingAsync.js +++ b/js/src/Ice/OutgoingAsync.js @@ -5,7 +5,7 @@ import { OutputStream } from "./Stream.js"; import { AsyncResult } from "./AsyncResult.js"; import { AsyncStatus } from "./AsyncStatus.js"; -import { UserException } from "./Exception.js"; +import { UserException } from "./UserException.js"; import { RetryException } from "./RetryException.js"; import { ReferenceMode } from "./ReferenceMode.js"; import { Ice as Ice_OperationMode } from "./OperationMode.js"; @@ -26,8 +26,8 @@ import { UnknownLocalException, UnknownUserException, UnknownReplyStatusException, -} from "./LocalException.js"; -import { LocalException } from "./Exception.js"; +} from "./LocalExceptions.js"; +import { LocalException } from "./LocalException.js"; import { Ice as Ice_Context } from "./Context.js"; const { ContextHelper } = Ice_Context; import { Protocol } from "./Protocol.js"; diff --git a/js/src/Ice/OutgoingConnectionFactory.js b/js/src/Ice/OutgoingConnectionFactory.js index 70130f7421b..cf98a419d73 100644 --- a/js/src/Ice/OutgoingConnectionFactory.js +++ b/js/src/Ice/OutgoingConnectionFactory.js @@ -6,8 +6,8 @@ import { ConnectionI } from "./ConnectionI.js"; import { HashMap } from "./HashMap.js"; import { AsyncResultBase } from "./AsyncResultBase.js"; import { Promise } from "./Promise.js"; -import { LocalException } from "./Exception.js"; -import { CommunicatorDestroyedException } from "./LocalException.js"; +import { LocalException } from "./LocalException.js"; +import { CommunicatorDestroyedException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; // diff --git a/js/src/Ice/Properties.js b/js/src/Ice/Properties.js index 87335cf1f18..0f99a03169c 100644 --- a/js/src/Ice/Properties.js +++ b/js/src/Ice/Properties.js @@ -5,7 +5,7 @@ import { StringUtil } from "./StringUtil.js"; import { PropertyNames } from "./PropertyNames.js"; import { getProcessLogger } from "./ProcessLogger.js"; -import { InitializationException } from "./LocalException.js"; +import { InitializationException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; const ParseStateKey = 0; diff --git a/js/src/Ice/Protocol.js b/js/src/Ice/Protocol.js index e117c636320..ac30e2cb940 100644 --- a/js/src/Ice/Protocol.js +++ b/js/src/Ice/Protocol.js @@ -3,7 +3,11 @@ // import { StringUtil } from "./StringUtil.js"; -import { UnsupportedEncodingException, UnsupportedProtocolException, VersionParseException } from "./LocalException.js"; +import { + UnsupportedEncodingException, + UnsupportedProtocolException, + VersionParseException, +} from "./LocalExceptions.js"; import { Ice as Ice_Version } from "./Version.js"; const { EncodingVersion, ProtocolVersion } = Ice_Version; diff --git a/js/src/Ice/Reference.js b/js/src/Ice/Reference.js index 8b8072a558d..bfa1fc78ef1 100644 --- a/js/src/Ice/Reference.js +++ b/js/src/Ice/Reference.js @@ -15,7 +15,7 @@ import { OpaqueEndpointI } from "./OpaqueEndpoint.js"; import { ReferenceMode } from "./ReferenceMode.js"; import { StringUtil } from "./StringUtil.js"; import { Encoding_1_0, Protocol_1_0, encodingVersionToString, protocolVersionToString } from "./Protocol.js"; -import { FixedProxyException, NoEndpointException } from "./LocalException.js"; +import { FixedProxyException, NoEndpointException } from "./LocalExceptions.js"; import { Promise } from "./Promise.js"; import { Debug } from "./Debug.js"; import { ConnectRequestHandler } from "./ConnectRequestHandler.js"; diff --git a/js/src/Ice/ReferenceFactory.js b/js/src/Ice/ReferenceFactory.js index 1389c1d1ea3..d6b21b349aa 100644 --- a/js/src/Ice/ReferenceFactory.js +++ b/js/src/Ice/ReferenceFactory.js @@ -19,7 +19,7 @@ import { IllegalIdentityException, ProxyParseException, ProxyUnmarshalException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { Ice as Ice_Version } from "./Version.js"; const { ProtocolVersion, EncodingVersion } = Ice_Version; import { Debug } from "./Debug.js"; diff --git a/js/src/Ice/RetryException.js b/js/src/Ice/RetryException.js index 4908a3c02ca..556dd9b6afa 100644 --- a/js/src/Ice/RetryException.js +++ b/js/src/Ice/RetryException.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { LocalException } from "./Exception.js"; +import { LocalException } from "./LocalException.js"; import { Debug } from "./Debug.js"; export class RetryException extends Error { diff --git a/js/src/Ice/RetryQueue.js b/js/src/Ice/RetryQueue.js index 67f86ce6362..e6c3c31a7c0 100644 --- a/js/src/Ice/RetryQueue.js +++ b/js/src/Ice/RetryQueue.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { CommunicatorDestroyedException } from "./LocalException.js"; +import { CommunicatorDestroyedException } from "./LocalExceptions.js"; class RetryTask { constructor(instance, queue, outAsync) { diff --git a/js/src/Ice/RouterInfo.js b/js/src/Ice/RouterInfo.js index a4d225cbb95..7318a5e0b11 100644 --- a/js/src/Ice/RouterInfo.js +++ b/js/src/Ice/RouterInfo.js @@ -4,7 +4,7 @@ import { HashMap } from "./HashMap.js"; import { Promise } from "./Promise.js"; -import { NoEndpointException } from "./LocalException.js"; +import { NoEndpointException } from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; import { ObjectPrx } from "./ObjectPrx.js"; diff --git a/js/src/Ice/ServantManager.js b/js/src/Ice/ServantManager.js index d23f6f4e2d8..af32f8d5c1e 100644 --- a/js/src/Ice/ServantManager.js +++ b/js/src/Ice/ServantManager.js @@ -4,7 +4,7 @@ import { HashMap } from "./HashMap.js"; import { StringUtil } from "./StringUtil.js"; -import { AlreadyRegisteredException, NotRegisteredException } from "./LocalException.js"; +import { AlreadyRegisteredException, NotRegisteredException } from "./LocalExceptions.js"; import { identityToString } from "./IdentityUtil.js"; import { Debug } from "./Debug.js"; diff --git a/js/src/Ice/Stream.js b/js/src/Ice/Stream.js index 46ddd0384e7..bbb075f79df 100644 --- a/js/src/Ice/Stream.js +++ b/js/src/Ice/Stream.js @@ -11,16 +11,15 @@ import { OptionalFormat } from "./OptionalFormat.js"; import { Encoding_1_0, Protocol } from "./Protocol.js"; import { SlicedData, SliceInfo, UnknownSlicedValue } from "./UnknownSlicedValue.js"; import { TraceUtil } from "./TraceUtil.js"; -import { LocalException } from "./Exception.js"; +import { LocalException } from "./LocalException.js"; import { Value } from "./Value.js"; import { EncapsulationException, InitializationException, MarshalException, UnmarshalOutOfBoundsException, - UnknownUserException, NoValueFactoryException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { Ice as Ice_Identity } from "./Identity.js"; const { Identity } = Ice_Identity; import { Ice as Ice_Version } from "./Version.js"; diff --git a/js/src/Ice/TcpEndpointI.js b/js/src/Ice/TcpEndpointI.js index fa43f219a37..fc1d4af04d7 100644 --- a/js/src/Ice/TcpEndpointI.js +++ b/js/src/Ice/TcpEndpointI.js @@ -5,7 +5,7 @@ import { HashUtil } from "./HashUtil.js"; import { StringUtil } from "./StringUtil.js"; import { TCPEndpointInfo } from "./Endpoint.js"; -import { EndpointParseException } from "./LocalException.js"; +import { EndpointParseException } from "./LocalExceptions.js"; import { IPEndpointI } from "./IPEndpointI.js"; import { TcpTransceiver } from "./TcpTransceiver.js"; import { Debug } from "./Debug.js"; diff --git a/js/src/Ice/TcpTransceiver.js b/js/src/Ice/TcpTransceiver.js index 2034b7bf7db..1e93e566b50 100644 --- a/js/src/Ice/TcpTransceiver.js +++ b/js/src/Ice/TcpTransceiver.js @@ -10,7 +10,7 @@ import { ConnectionRefusedException, ConnectFailedException, SocketException, -} from "./LocalException.js"; +} from "./LocalExceptions.js"; import { Debug } from "./Debug.js"; import net from "net"; diff --git a/js/src/Ice/Timer.js b/js/src/Ice/Timer.js index 827f4c77909..89b13f03b4b 100644 --- a/js/src/Ice/Timer.js +++ b/js/src/Ice/Timer.js @@ -3,7 +3,7 @@ // import { TimerUtil } from "./TimerUtil.js"; -import { CommunicatorDestroyedException } from "./LocalException.js"; +import { CommunicatorDestroyedException } from "./LocalExceptions.js"; export class Timer { constructor(logger) { diff --git a/js/src/Ice/UserException.d.ts b/js/src/Ice/UserException.d.ts new file mode 100644 index 00000000000..b357ead7486 --- /dev/null +++ b/js/src/Ice/UserException.d.ts @@ -0,0 +1,18 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +declare module "ice" { + namespace Ice { + /** + * Base class for all Ice user exceptions. + */ + abstract class UserException extends Exception { + /** + * Obtains the Slice type ID of this exception. + * @return The fully-scoped type ID. + */ + static ice_staticId(): string; + } + } +} diff --git a/js/src/Ice/UserException.js b/js/src/Ice/UserException.js new file mode 100644 index 00000000000..a02585b18c9 --- /dev/null +++ b/js/src/Ice/UserException.js @@ -0,0 +1,78 @@ +// +// Copyright (c) ZeroC, Inc. All rights reserved. +// + +import { Exception } from "./Exception.js"; + +export class UserException extends Exception { + constructor() { + super(); + Exception.captureStackTrace(this); + } + + static get _id() { + return "::Ice::UserException"; + } + + _write(os) { + os.startException(); + writeImpl(this, os, this._mostDerivedType()); + os.endException(); + } + + _read(is) { + is.startException(); + readImpl(this, is, this._mostDerivedType()); + is.endException(); + } + + _usesClasses() { + return false; + } + + _mostDerivedType() { + return UserException; + } +} + +// +// Private methods +// + +const writeImpl = function (obj, os, type) { + // + // The writeImpl method is a recursive method that goes down the + // class hierarchy to marshal each slice of the class using the + // generated _writeMemberImpl method. + // + + if (type === undefined || type === UserException) { + return; // Don't marshal anything for Ice.UserException + } + + os.startSlice(type._id, -1, type._parent === UserException); + if (type.prototype.hasOwnProperty("_writeMemberImpl")) { + type.prototype._writeMemberImpl.call(obj, os); + } + os.endSlice(); + writeImpl(obj, os, type._parent); +}; + +const readImpl = function (obj, is, type) { + // + // The readImpl method is a recursive method that goes down the + // class hierarchy to marshal each slice of the class using the + // generated _readMemberImpl method. + // + + if (type === undefined || type === UserException) { + return; // Don't marshal anything for UserException + } + + is.startSlice(); + if (type.prototype.hasOwnProperty("_readMemberImpl")) { + type.prototype._readMemberImpl.call(obj, is); + } + is.endSlice(); + readImpl(obj, is, type._parent); +}; diff --git a/js/src/Ice/ValueFactoryManager.js b/js/src/Ice/ValueFactoryManager.js index 4745dcca368..a5f30b88757 100644 --- a/js/src/Ice/ValueFactoryManager.js +++ b/js/src/Ice/ValueFactoryManager.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { AlreadyRegisteredException } from "./LocalException.js"; +import { AlreadyRegisteredException } from "./LocalExceptions.js"; // Only for use by Instance export class ValueFactoryManager { diff --git a/js/src/Ice/WSEndpoint.js b/js/src/Ice/WSEndpoint.js index 833510658be..3056bc2a673 100644 --- a/js/src/Ice/WSEndpoint.js +++ b/js/src/Ice/WSEndpoint.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { EndpointParseException } from "./LocalException.js"; +import { EndpointParseException } from "./LocalExceptions.js"; import { HashUtil } from "./HashUtil.js"; import { WSEndpointInfo } from "./Endpoint.js"; import { EndpointI } from "./EndpointI.js"; diff --git a/js/src/Ice/WSTransceiver.js b/js/src/Ice/WSTransceiver.js index b82ede3b858..6a70f0d8293 100644 --- a/js/src/Ice/WSTransceiver.js +++ b/js/src/Ice/WSTransceiver.js @@ -2,7 +2,7 @@ // Copyright (c) ZeroC, Inc. All rights reserved. // -import { ConnectFailedException, ConnectionLostException, SocketException } from "./LocalException.js"; +import { ConnectFailedException, ConnectionLostException, SocketException } from "./LocalExceptions.js"; import { WSConnectionInfo, TCPConnectionInfo } from "./Connection.js"; import { ConnectionInfo as SSLConnectionInfo } from "./SSL/ConnectionInfo.js"; import { SocketOperation } from "./SocketOperation.js"; diff --git a/js/src/Ice/index.d.ts b/js/src/Ice/index.d.ts index b35a2fce01d..93b958f4c00 100644 --- a/js/src/Ice/index.d.ts +++ b/js/src/Ice/index.d.ts @@ -30,6 +30,7 @@ /// /// /// +/// /// /// /// @@ -48,4 +49,5 @@ /// /// /// +/// /// diff --git a/js/src/Ice/index.js b/js/src/Ice/index.js index dd05f1590b9..1b92b740019 100644 --- a/js/src/Ice/index.js +++ b/js/src/Ice/index.js @@ -31,6 +31,7 @@ import * as Ice_Instance from "./Instance.js"; // Must be imported after Instance.js for the prototype extensions. import "./InstanceExtensions.js"; import * as Ice_LocalException from "./LocalException.js"; +import * as Ice_LocalExceptions from "./LocalExceptions.js"; import * as Ice_Locator from "./Locator.js"; import * as Ice_LocatorInfo from "./LocatorInfo.js"; import * as Ice_Logger from "./Logger.js"; @@ -70,6 +71,7 @@ import * as Ice_ToStringMode from "./ToStringMode.js"; import * as Ice_TraceLevels from "./TraceLevels.js"; import * as Ice_TraceUtil from "./TraceUtil.js"; import * as Ice_UnknownSlicedValue from "./UnknownSlicedValue.js"; +import * as Ice_UserException from "./UserException.js"; import * as Ice_Value from "./Value.js"; import * as Ice_ValueFactoryManager from "./ValueFactoryManager.js"; import * as Ice_Version from "./Version.js"; @@ -103,6 +105,7 @@ export const Ice = { ...Ice_Initialize, ...Ice_Instance, ...Ice_LocalException, + ...Ice_LocalExceptions, ...Ice_LocatorInfo, ...Ice_Logger, ...Ice_Long, @@ -131,6 +134,7 @@ export const Ice = { ...Ice_TraceLevels, ...Ice_TraceUtil, ...Ice_UnknownSlicedValue, + ...Ice_UserException, ...Ice_Value, ...Ice_ValueFactoryManager,