From d89025bee3e86199ef69f4b0419edfad688015e3 Mon Sep 17 00:00:00 2001 From: Sophia Chu <112967780+sophia-bq@users.noreply.github.com> Date: Mon, 27 Jan 2025 13:04:49 -0800 Subject: [PATCH] chore: rename exception to error (#388) --- .../aws_secrets_manager_plugin.ts | 4 +-- .../iam_authentication_plugin.ts | 2 +- common/lib/plugin_manager.ts | 4 +-- common/lib/plugins/efm/monitor.ts | 4 +-- .../plugins/efm/monitor_connection_context.ts | 2 +- .../lib/plugins/failover/failover_plugin.ts | 6 ++--- .../failover/reader_failover_handler.ts | 4 +-- .../failover/reader_failover_result.ts | 6 ++--- .../failover/writer_failover_handler.ts | 10 +++---- .../failover/writer_failover_result.ts | 6 ++--- .../federated_auth/federated_auth_plugin.ts | 2 +- .../federated_auth/okta_auth_plugin.ts | 4 +-- .../limitless/limitless_router_service.ts | 2 +- .../plugins/read_write_splitting_plugin.ts | 4 +-- common/lib/utils/locales/en.json | 27 +++++++++---------- .../UsingTheNodejsWrapper.md | 2 +- .../aws_dev_postgresql_example.ts | 4 +-- .../aws_failover_mysql_example.ts | 2 +- .../aws_failover_postgresql_example.ts | 2 +- ..._pool_password_warning_postgres_example.ts | 4 +-- ...ion_pool_password_warning_mysql_example.ts | 4 +-- ...ternal_connection_pooling_mysql_example.ts | 2 +- ...nal_connection_pooling_postgres_example.ts | 2 +- .../aws_read_write_splitting_mysql_example.ts | 2 +- ...read_write_splitting_postgresql_example.ts | 2 +- ...fastest_response_strategy_mysql_example.ts | 2 +- ...test_response_strategy_postgres_example.ts | 2 +- mysql/lib/dialect/mysql2_driver_dialect.ts | 2 +- tests/unit/aurora_connection_tracker.test.ts | 12 ++++----- tests/unit/aws_secrets_manager_plugin.test.ts | 2 +- tests/unit/dev_plugin.test.ts | 12 ++++----- tests/unit/failover_plugin.test.ts | 6 ++--- tests/unit/host_monitoring_plugin.test.ts | 4 +-- tests/unit/rds_host_list_provider.test.ts | 2 +- tests/unit/writer_failover_handler.test.ts | 4 +-- 35 files changed, 80 insertions(+), 81 deletions(-) diff --git a/common/lib/authentication/aws_secrets_manager_plugin.ts b/common/lib/authentication/aws_secrets_manager_plugin.ts index 108fad97..d47004fe 100644 --- a/common/lib/authentication/aws_secrets_manager_plugin.ts +++ b/common/lib/authentication/aws_secrets_manager_plugin.ts @@ -123,7 +123,7 @@ export class AwsSecretsManagerPlugin extends AbstractConnectionPlugin { return await connectFunc(); } } - logger.debug(Messages.get("AwsSecretsManagerConnectionPlugin.unhandledException", error.name, error.message)); + logger.debug(Messages.get("AwsSecretsManagerConnectionPlugin.unhandledError", error.name, error.message)); } throw error; } @@ -149,7 +149,7 @@ export class AwsSecretsManagerPlugin extends AbstractConnectionPlugin { } else if (error instanceof Error && error.message.includes("AWS SDK error")) { logAndThrowError(Messages.get("AwsSecretsManagerConnectionPlugin.endpointOverrideInvalidConnection", error.message)); } else { - logAndThrowError(Messages.get("AwsSecretsManagerConnectionPlugin.unhandledException", error.message)); + logAndThrowError(Messages.get("AwsSecretsManagerConnectionPlugin.unhandledError", error.message)); } } } diff --git a/common/lib/authentication/iam_authentication_plugin.ts b/common/lib/authentication/iam_authentication_plugin.ts index ebef18b4..8f4dec4e 100644 --- a/common/lib/authentication/iam_authentication_plugin.ts +++ b/common/lib/authentication/iam_authentication_plugin.ts @@ -109,7 +109,7 @@ export class IamAuthenticationPlugin extends AbstractConnectionPlugin { try { return await connectFunc(); } catch (e) { - logger.debug(Messages.get("Authentication.connectException", (e as Error).message)); + logger.debug(Messages.get("Authentication.connectError", (e as Error).message)); if (!this.pluginService.isLoginError(e as Error) || !isCachedToken) { throw e; } diff --git a/common/lib/plugin_manager.ts b/common/lib/plugin_manager.ts index 9409dad3..013e7862 100644 --- a/common/lib/plugin_manager.ts +++ b/common/lib/plugin_manager.ts @@ -321,7 +321,7 @@ export class PluginManager { try { host = plugin.getHostInfoByStrategy(role, strategy, hosts); } catch (error) { - // This plugin does not support the provided strategy, ignore the exception and move on + // This plugin does not support the provided strategy, ignore the error and move on. } } } @@ -338,7 +338,7 @@ export class PluginManager { return host; } } catch (error) { - // This plugin does not support the provided strategy, ignore the exception and move on + // This plugin does not support the provided strategy, ignore the error and move on. } } } diff --git a/common/lib/plugins/efm/monitor.ts b/common/lib/plugins/efm/monitor.ts index 4733cf89..301df40a 100644 --- a/common/lib/plugins/efm/monitor.ts +++ b/common/lib/plugins/efm/monitor.ts @@ -207,11 +207,11 @@ export class MonitorImpl implements Monitor { }); } } catch (error: any) { - logger.debug(Messages.get("MonitorImpl.exceptionDuringMonitoringContinue", error.message)); + logger.debug(Messages.get("MonitorImpl.errorDuringMonitoringContinue", error.message)); } } } catch (error: any) { - logger.debug(Messages.get("MonitorImpl.exceptionDuringMonitoringStop", error.message)); + logger.debug(Messages.get("MonitorImpl.errorDuringMonitoringStop", error.message)); } finally { this.stopped = true; await this.endMonitoringClient(); diff --git a/common/lib/plugins/efm/monitor_connection_context.ts b/common/lib/plugins/efm/monitor_connection_context.ts index 1ef12113..3781da62 100644 --- a/common/lib/plugins/efm/monitor_connection_context.ts +++ b/common/lib/plugins/efm/monitor_connection_context.ts @@ -77,7 +77,7 @@ export class MonitorConnectionContext { this.telemetryAbortedConnectionCounter.inc(); } catch (error: any) { // ignore - logger.debug(Messages.get("MonitorConnectionContext.exceptionAbortingConnection", error.message)); + logger.debug(Messages.get("MonitorConnectionContext.errorAbortingConnection", error.message)); } this.abortedConnectionCounter++; } diff --git a/common/lib/plugins/failover/failover_plugin.ts b/common/lib/plugins/failover/failover_plugin.ts index 638c3ee4..bbbb56a4 100644 --- a/common/lib/plugins/failover/failover_plugin.ts +++ b/common/lib/plugins/failover/failover_plugin.ts @@ -321,7 +321,7 @@ export class FailoverPlugin extends AbstractConnectionPlugin { return await methodFunc(); } catch (e: any) { - logger.debug(Messages.get("Failover.detectedException", e.message)); + logger.debug(Messages.get("Failover.detectedError", e.message)); if (this._lastError !== e && this.shouldErrorTriggerClientSwitch(e)) { await this.invalidateCurrentClient(); const currentHostInfo = this.pluginService.getCurrentHostInfo(); @@ -368,7 +368,7 @@ export class FailoverPlugin extends AbstractConnectionPlugin { const result = await this._readerFailoverHandler.failover(this.pluginService.getHosts(), failedHost); if (result) { - const error = result.exception; + const error = result.error; if (error) { throw error; } @@ -424,7 +424,7 @@ export class FailoverPlugin extends AbstractConnectionPlugin { const result = await this._writerFailoverHandler.failover(this.pluginService.getHosts()); if (result) { - const error = result.exception; + const error = result.error; if (error) { throw error; } diff --git a/common/lib/plugins/failover/reader_failover_handler.ts b/common/lib/plugins/failover/reader_failover_handler.ts index 568146a2..398c90e4 100644 --- a/common/lib/plugins/failover/reader_failover_handler.ts +++ b/common/lib/plugins/failover/reader_failover_handler.ts @@ -148,7 +148,7 @@ export class ClusterAwareReaderFailoverHandler implements ReaderFailoverHandler // submit connection attempt tasks in batches of 2 try { const result = await this.getResultFromNextTaskBatch(hosts, i, failoverTaskId); - if (result && (result.isConnected || result.exception)) { + if (result && (result.isConnected || result.error)) { return result; } } catch (error) { @@ -326,7 +326,7 @@ class ConnectionAttemptTask { } catch (error) { this.pluginService.setAvailability(this.newHost.allAliases, HostAvailability.NOT_AVAILABLE); if (error instanceof Error) { - // Propagate exceptions that are not caused by network errors. + // Propagate errors that are not caused by network errors. if (!this.pluginService.isNetworkError(error)) { return new ReaderFailoverResult(null, null, false, error, this.taskId); } diff --git a/common/lib/plugins/failover/reader_failover_result.ts b/common/lib/plugins/failover/reader_failover_result.ts index 959789c1..0657e4cf 100644 --- a/common/lib/plugins/failover/reader_failover_result.ts +++ b/common/lib/plugins/failover/reader_failover_result.ts @@ -21,14 +21,14 @@ export class ReaderFailoverResult { readonly client: ClientWrapper | null; readonly newHost: HostInfo | null; readonly isConnected: boolean; - readonly exception?: Error; + readonly error?: Error; readonly taskId?: number; - constructor(client: ClientWrapper | null, newHost: HostInfo | null, isConnected: boolean, exception?: Error, taskId?: number) { + constructor(client: ClientWrapper | null, newHost: HostInfo | null, isConnected: boolean, error?: Error, taskId?: number) { this.client = client; this.newHost = newHost; this.isConnected = isConnected; - this.exception = exception; + this.error = error; this.taskId = taskId; } } diff --git a/common/lib/plugins/failover/writer_failover_handler.ts b/common/lib/plugins/failover/writer_failover_handler.ts index 7d4cc5e3..aa044795 100644 --- a/common/lib/plugins/failover/writer_failover_handler.ts +++ b/common/lib/plugins/failover/writer_failover_handler.ts @@ -113,7 +113,7 @@ export class ClusterAwareWriterFailoverHandler implements WriterFailoverHandler .then((result) => { selectedTask = result.taskName; // If the first resolved promise is connected or has an error, return it. - if (result.isConnected || result.exception || singleTask) { + if (result.isConnected || result.error || singleTask) { return result; } @@ -239,9 +239,9 @@ class ReconnectToWriterHandlerTask { await this.pluginService.forceRefreshHostList(this.currentClient); latestTopology = this.pluginService.getHosts(); } catch (error) { - // Propagate exceptions that are not caused by network errors. + // Propagate errors that are not caused by network errors. if (error instanceof AwsWrapperError && !this.pluginService.isNetworkError(error)) { - logger.info(Messages.get("ClusterAwareWriterFailoverHandler.taskAEncounteredException", error.message)); + logger.info(Messages.get("ClusterAwareWriterFailoverHandler.taskAEncounteredError", error.message)); return new WriterFailoverResult(false, false, [], ClusterAwareWriterFailoverHandler.RECONNECT_WRITER_TASK, null, error); } } @@ -342,7 +342,7 @@ class WaitForNewWriterHandlerTask { return new WriterFailoverResult(true, true, this.currentTopology, ClusterAwareWriterFailoverHandler.WAIT_NEW_WRITER_TASK, this.currentClient); } catch (error: any) { - logger.error(Messages.get("ClusterAwareWriterFailoverHandler.taskBEncounteredException", error.message)); + logger.error(Messages.get("ClusterAwareWriterFailoverHandler.taskBEncounteredError", error.message)); throw error; } finally { logger.info(Messages.get("ClusterAwareWriterFailoverHandler.taskBFinished")); @@ -410,7 +410,7 @@ class WaitForNewWriterHandlerTask { } } } catch (error: any) { - logger.info(Messages.get("ClusterAwareWriterFailoverHandler.taskBEncounteredException", error.message)); + logger.info(Messages.get("ClusterAwareWriterFailoverHandler.taskBEncounteredError", error.message)); return false; } diff --git a/common/lib/plugins/failover/writer_failover_result.ts b/common/lib/plugins/failover/writer_failover_result.ts index 01902bd5..d8d96191 100644 --- a/common/lib/plugins/failover/writer_failover_result.ts +++ b/common/lib/plugins/failover/writer_failover_result.ts @@ -23,14 +23,14 @@ export class WriterFailoverResult { readonly topology: HostInfo[]; readonly client: ClientWrapper | null; readonly taskName: string; - readonly exception: Error | undefined; + readonly error: Error | undefined; - constructor(isConnected: boolean, isNewHost: boolean, topology: HostInfo[], taskName: string, client: ClientWrapper | null, exception?: Error) { + constructor(isConnected: boolean, isNewHost: boolean, topology: HostInfo[], taskName: string, client: ClientWrapper | null, error?: Error) { this.isConnected = isConnected; this.isNewHost = isNewHost; this.topology = topology; this.client = client; this.taskName = taskName; - this.exception = exception; + this.error = error; } } diff --git a/common/lib/plugins/federated_auth/federated_auth_plugin.ts b/common/lib/plugins/federated_auth/federated_auth_plugin.ts index df77ace8..8ce215c0 100644 --- a/common/lib/plugins/federated_auth/federated_auth_plugin.ts +++ b/common/lib/plugins/federated_auth/federated_auth_plugin.ts @@ -96,7 +96,7 @@ export class FederatedAuthPlugin extends AbstractConnectionPlugin { await this.updateAuthenticationToken(hostInfo, props, region, cacheKey, host); return await connectFunc(); } catch (e: any) { - throw new AwsWrapperError(Messages.get("SamlAuthPlugin.unhandledException", e.message)); + throw new AwsWrapperError(Messages.get("SamlAuthPlugin.unhandledError", e.message)); } } } diff --git a/common/lib/plugins/federated_auth/okta_auth_plugin.ts b/common/lib/plugins/federated_auth/okta_auth_plugin.ts index 294c0d4b..65be3bba 100644 --- a/common/lib/plugins/federated_auth/okta_auth_plugin.ts +++ b/common/lib/plugins/federated_auth/okta_auth_plugin.ts @@ -90,14 +90,14 @@ export class OktaAuthPlugin extends AbstractConnectionPlugin { return await connectFunc(); } catch (e: any) { if (!this.pluginService.isLoginError(e as Error) || !isCachedToken) { - logger.debug(Messages.get("Authentication.connectException", e.message)); + logger.debug(Messages.get("Authentication.connectError", e.message)); throw e; } try { await this.updateAuthenticationToken(hostInfo, props, region, cacheKey, host); return await connectFunc(); } catch (e: any) { - throw new AwsWrapperError(Messages.get("SamlAuthPlugin.unhandledException", e.message)); + throw new AwsWrapperError(Messages.get("SamlAuthPlugin.unhandledError", e.message)); } } } diff --git a/common/lib/plugins/limitless/limitless_router_service.ts b/common/lib/plugins/limitless/limitless_router_service.ts index e9a43726..85ddfa9f 100644 --- a/common/lib/plugins/limitless/limitless_router_service.ts +++ b/common/lib/plugins/limitless/limitless_router_service.ts @@ -202,7 +202,7 @@ export class LimitlessRouterServiceImpl implements LimitlessRouterService { } await sleep(retryIntervalMs); } catch (e) { - logger.debug(Messages.get("LimitlessRouterServiceImpl.getLimitlessRoutersException", e.message)); + logger.debug(Messages.get("LimitlessRouterServiceImpl.getLimitlessRoutersError", e.message)); } } while (remainingAttempts-- >= 0); diff --git a/common/lib/plugins/read_write_splitting_plugin.ts b/common/lib/plugins/read_write_splitting_plugin.ts index 56d3a110..cf9ce4c3 100644 --- a/common/lib/plugins/read_write_splitting_plugin.ts +++ b/common/lib/plugins/read_write_splitting_plugin.ts @@ -171,10 +171,10 @@ export class ReadWriteSplittingPlugin extends AbstractConnectionPlugin implement return await executeFunc(); } catch (error: any) { if (error instanceof FailoverError) { - logger.debug(Messages.get("ReadWriteSplittingPlugin.failoverExceptionWhileExecutingCommand", methodName)); + logger.debug(Messages.get("ReadWriteSplittingPlugin.failoverErrorWhileExecutingCommand", methodName)); await this.closeIdleClients(); } else { - logger.debug(Messages.get("ReadWriteSplittingPlugin.exceptionWhileExecutingCommand", methodName, error.message)); + logger.debug(Messages.get("ReadWriteSplittingPlugin.errorWhileExecutingCommand", methodName, error.message)); } throw error; diff --git a/common/lib/utils/locales/en.json b/common/lib/utils/locales/en.json index 2c48b105..344b65eb 100644 --- a/common/lib/utils/locales/en.json +++ b/common/lib/utils/locales/en.json @@ -19,7 +19,7 @@ "HostInfo.weightLessThanZero": "A HostInfo object was created with a weight value less than 0.", "AwsSecretsManagerConnectionPlugin.failedToFetchDbCredentials": "Was not able to either fetch or read the database credentials from AWS Secrets Manager. Ensure the correct secretId and region properties have been provided.", "AwsSecretsManagerConnectionPlugin.missingRequiredConfigParameter": "Configuration parameter '%s' is required.", - "AwsSecretsManagerConnectionPlugin.unhandledException": "Unhandled exception: '%s'", + "AwsSecretsManagerConnectionPlugin.unhandledError": "Unhandled error: '%s'", "AwsSecretsManagerConnectionPlugin.endpointOverrideInvalidConnection": "A connection to the provided endpoint could not be established: '%s'.", "ClusterAwareReaderFailoverHandler.invalidTopology": "'%s' was called with an invalid (null or empty) topology", "ClusterAwareReaderFailoverHandler.attemptingReaderConnection": "Trying to connect to reader: '%s', with properties '%s'", @@ -38,10 +38,10 @@ "ClusterAwareWriterFailoverHandler.successfullyConnectedToNewWriterInstance": "Successfully connected to the new writer instance: '%s'- '%s'", "ClusterAwareWriterFailoverHandler.successfullyReconnectedToWriterInstance": "Successfully re-connected to the current writer instance: '%s'- '%s'", "ClusterAwareWriterFailoverHandler.taskAAttemptReconnectToWriterInstance": "[TaskA] Attempting to re-connect to the current writer instance: '%s', with properties '%s'", - "ClusterAwareWriterFailoverHandler.taskAEncounteredException": "[TaskA] encountered an exception: '%s'", + "ClusterAwareWriterFailoverHandler.taskAEncounteredError": "[TaskA] encountered an error: '%s'", "ClusterAwareWriterFailoverHandler.taskAFinished": "[TaskA] Finished", "ClusterAwareWriterFailoverHandler.taskBAttemptConnectionToNewWriterInstance": "[TaskB] Attempting to connect to a new writer instance, with properties '%s'", - "ClusterAwareWriterFailoverHandler.taskBEncounteredException": "[TaskB] encountered an exception: '%s'", + "ClusterAwareWriterFailoverHandler.taskBEncounteredError": "[TaskB] encountered an error: '%s'", "ClusterAwareWriterFailoverHandler.taskBFinished": "[TaskB] Finished", "ClusterAwareWriterFailoverHandler.taskBConnectedToReader": "[TaskB] Connected to reader: '%s'", "ClusterAwareWriterFailoverHandler.taskBFailedToConnectToAnyReader": "[TaskB] Failed to connect to any reader.", @@ -55,7 +55,7 @@ "Failover.unableToConnectToWriter": "Unable to establish SQL connection to the writer instance.", "Failover.unableToConnectToReader": "Unable to establish SQL connection to the reader instance.", "Failover.unableToDetermineWriter": "Unable to determine the current writer instance.", - "Failover.detectedException": "Detected an exception while executing a command: %s", + "Failover.detectedError": "Detected an error while executing a command: %s", "Failover.failoverDisabled": "Cluster-aware failover is disabled.", "Failover.establishedConnection": "Connected to %s", "Failover.startWriterFailover": "Starting writer failover procedure.", @@ -91,8 +91,8 @@ "ReadWriteSplittingPlugin.noWriterFound": "No writer was found in the current host list.", "ReadWriteSplittingPlugin.noReadersFound": "A reader instance was requested via setReadOnly, but there are no readers in the host list. The current writer will be used as a fallback: '%s'", "ReadWriteSplittingPlugin.emptyHostList": "Host list is empty.", - "ReadWriteSplittingPlugin.exceptionWhileExecutingCommand": "[ReadWriteSplitting] Detected an exception while executing a command: '%s', '%s'", - "ReadWriteSplittingPlugin.failoverExceptionWhileExecutingCommand": "Detected a failover exception while executing a command: '%s'", + "ReadWriteSplittingPlugin.errorWhileExecutingCommand": "[ReadWriteSplitting] Detected an error while executing a command: '%s', '%s'", + "ReadWriteSplittingPlugin.failoverErrorWhileExecutingCommand": "Detected a failover error while executing a command: '%s'", "ReadWriteSplittingPlugin.noReadersAvailable": "The plugin was unable to establish a reader client to any reader instance.", "ReadWriteSplittingPlugin.successfullyConnectedToReader": "Successfully connected to a new reader host: '%s'", "ReadWriteSplittingPlugin.failedToConnectToReader": "Failed to connect to reader host: '%s'", @@ -106,8 +106,7 @@ "AdfsCredentialsProviderFactory.signOnPageRequestFailed": "ADFS SignOn Page Request Failed with HTTP status '%s', reason phrase '%s', and response '%s'", "AdfsCredentialsProviderFactory.signOnPageUrl": "ADFS SignOn URL: '%s'", "Authentication.unsupportedHostname": "Unsupported AWS hostname '%s'. Amazon domain name in format *.AWS-Region.rds.amazonaws.com or *.rds.AWS-Region.amazonaws.com.cn is expected.", - "Authentication.connectException": "Error occurred while opening a connection: %s", - "Authentication.unhandledException": "Unhandled exception: %s", + "Authentication.connectError": "Error occurred while opening a connection: %s", "Authentication.invalidPort": "Port number: %d is not valid. Port number should be greater than zero. Falling back to default port.", "AuthenticationToken.tokenExpirationLessThanZero": "Authentication token expiration time must be a non-negative value.", "AuthenticationToken.useCachedToken": "Use cached authentication token = '%s'", @@ -117,17 +116,17 @@ "OktaCredentialsProviderFactory.invalidSessionToken": "Invalid response from session token request to Okta.", "OktaCredentialsProviderFactory.invalidSamlResponse": "The SAML Assertion request did not return a valid response containing a SAMLResponse.", "OktaCredentialsProviderFactory.samlRequestFailed": "Okta SAML Assertion request failed with HTTP status '%s', reason phrase '%s', and response '%s'", - "SamlCredentialsProviderFactory.getSamlAssertionFailed": "Failed to get SAML Assertion due to exception: '%s'", - "SamlAuthPlugin.unhandledException": "Unhandled exception: '%s'", + "SamlCredentialsProviderFactory.getSamlAssertionFailed": "Failed to get SAML Assertion due to error: '%s'", + "SamlAuthPlugin.unhandledError": "Unhandled error: '%s'", "HostAvailabilityStrategy.invalidMaxRetries": "Invalid value of '%s' for configuration parameter `hostAvailabilityStrategyMaxRetries`. It must be an integer greater or equal to 1.", "HostAvailabilityStrategy.invalidInitialBackoffTime": "Invalid value of '%s' for configuration parameter `hostAvailabilityStrategyInitialBackoffTime`. It must be an integer greater or equal to 1.", - "MonitorConnectionContext.exceptionAbortingConnection": "Exception during aborting connection: %s.", + "MonitorConnectionContext.errorAbortingConnection": "Error during aborting connection: %s.", "MonitorConnectionContext.hostDead": "Host %s is *dead*.", "MonitorConnectionContext.hostNotResponding": "Host %s is not *responding* %s", "MonitorConnectionContext.hostAlive": "Host %s is *alive*.", "MonitorImpl.contextNullWarning": "Parameter 'context' should not be null or undefined.", - "MonitorImpl.exceptionDuringMonitoringContinue": "Continuing monitoring after unhandled exception was thrown in monitoring for host %s.", - "MonitorImpl.exceptionDuringMonitoringStop": "Stopping monitoring after unhandled exception was thrown during monitoring for host %s.", + "MonitorImpl.errorDuringMonitoringContinue": "Continuing monitoring after unhandled error was thrown in monitoring for host %s.", + "MonitorImpl.errorDuringMonitoringStop": "Stopping monitoring after unhandled error was thrown during monitoring for host %s.", "MonitorImpl.monitorIsStopped": "Monitoring was already stopped for host %s.", "MonitorImpl.stopped": "Stopped monitoring for host '%s'.", "MonitorImpl.startMonitoring": "Start monitoring for %s.", @@ -181,7 +180,7 @@ "LimitlessRouterServiceImpl.incorrectConfiguration": "Limitless Connection Plugin is unable to run. Please ensure the connection settings are correct.", "LimitlessRouterServiceImpl.maxRetriesExceeded": "Max number of connection retries has been exceeded.", "LimitlessRouterServiceImpl.synchronouslyGetLimitlessRouters": "Fetching Limitless Routers synchronously.", - "LimitlessRouterServiceImpl.getLimitlessRoutersException": "Exception encountered getting Limitless Routers. %s", + "LimitlessRouterServiceImpl.getLimitlessRoutersError": "Error encountered getting Limitless Routers. %s", "LimitlessRouterServiceImpl.fetchedEmptyRouterList": "Empty router list was fetched.", "LimitlessRouterServiceImpl.errorStartingMonitor": "An error occurred while starting Limitless Router Monitor. %s", "AwsCredentialsManager.wrongHandler": "Provided AWS credential provider handler should implement AwsCredentialsProviderHandler.", diff --git a/docs/using-the-nodejs-wrapper/UsingTheNodejsWrapper.md b/docs/using-the-nodejs-wrapper/UsingTheNodejsWrapper.md index 8bf37b54..2c67b848 100644 --- a/docs/using-the-nodejs-wrapper/UsingTheNodejsWrapper.md +++ b/docs/using-the-nodejs-wrapper/UsingTheNodejsWrapper.md @@ -145,7 +145,7 @@ Besides a list of plugins to load and configuration properties, configuration pr - [Database Dialect](./DatabaseDialects.md#database-dialects) - [Driver Dialect](../../common/lib/driver_dialect/driver_dialect.ts) -- a custom exception handler +- a custom error handler - a custom connection provider The following example creates and sets a configuration profile: diff --git a/examples/aws_driver_example/aws_dev_postgresql_example.ts b/examples/aws_driver_example/aws_dev_postgresql_example.ts index 9d06b1da..1bf715d5 100644 --- a/examples/aws_driver_example/aws_dev_postgresql_example.ts +++ b/examples/aws_driver_example/aws_dev_postgresql_example.ts @@ -38,7 +38,7 @@ const client = new AwsPGClient({ plugins: "dev" }); -// Simulate an exception while opening a new connection. +// Simulate an error while opening a new connection. ErrorSimulatorManager.raiseErrorOnNextConnect(errorToRaise); // Attempt connection. Throws errorToRaise. @@ -65,7 +65,7 @@ try { // Query executes normally without error. const anotherResult = await client.query("select 1"); -// Check call parameters to decide whether to return an exception or not. +// Check call parameters to decide whether to return an error or not. class TestErrorCallback implements ErrorSimulatorMethodCallback { getErrorToRaise(methodName: string, methodArgs: any): Error | null { if (methodName == "query" && methodArgs == "select 1") { diff --git a/examples/aws_driver_example/aws_failover_mysql_example.ts b/examples/aws_driver_example/aws_failover_mysql_example.ts index 27dda850..86700560 100644 --- a/examples/aws_driver_example/aws_failover_mysql_example.ts +++ b/examples/aws_driver_example/aws_failover_mysql_example.ts @@ -64,7 +64,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/aws_failover_postgresql_example.ts b/examples/aws_driver_example/aws_failover_postgresql_example.ts index 7793fa54..c65b56fe 100644 --- a/examples/aws_driver_example/aws_failover_postgresql_example.ts +++ b/examples/aws_driver_example/aws_failover_postgresql_example.ts @@ -64,7 +64,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/aws_interal_connection_pool_password_warning_postgres_example.ts b/examples/aws_driver_example/aws_interal_connection_pool_password_warning_postgres_example.ts index 33907a57..71d3909e 100644 --- a/examples/aws_driver_example/aws_interal_connection_pool_password_warning_postgres_example.ts +++ b/examples/aws_driver_example/aws_interal_connection_pool_password_warning_postgres_example.ts @@ -85,11 +85,11 @@ const newClient2 = new AwsPGClient({ plugins: "readWriteSplitting" }); -// Correctly throws an exception - creates a fresh connection pool which will check the password +// Correctly throws an error - creates a fresh connection pool which will check the password // because there are no cached pool connections. try { await newClient2.connect(); - // Will not reach - exception will be thrown + // Will not reach - error will be thrown. } finally { // Clean up resources used by the plugins. await PluginManager.releaseResources(); diff --git a/examples/aws_driver_example/aws_internal_connection_pool_password_warning_mysql_example.ts b/examples/aws_driver_example/aws_internal_connection_pool_password_warning_mysql_example.ts index d6782ddb..8c8e6464 100644 --- a/examples/aws_driver_example/aws_internal_connection_pool_password_warning_mysql_example.ts +++ b/examples/aws_driver_example/aws_internal_connection_pool_password_warning_mysql_example.ts @@ -85,11 +85,11 @@ const newClient2 = new AwsMySQLClient({ plugins: "readWriteSplitting" }); -// Correctly throws an exception - creates a fresh connection pool which will check the password +// Correctly throws an error - creates a fresh connection pool which will check the password // because there are no cached pool connections. try { await newClient2.connect(); - // Will not reach - exception will be thrown. + // Will not reach - error will be thrown. } finally { // Clean up resources used by the plugins. await PluginManager.releaseResources(); diff --git a/examples/aws_driver_example/aws_internal_connection_pooling_mysql_example.ts b/examples/aws_driver_example/aws_internal_connection_pooling_mysql_example.ts index f207f87c..8608dfbe 100644 --- a/examples/aws_driver_example/aws_internal_connection_pooling_mysql_example.ts +++ b/examples/aws_driver_example/aws_internal_connection_pooling_mysql_example.ts @@ -102,7 +102,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/aws_internal_connection_pooling_postgres_example.ts b/examples/aws_driver_example/aws_internal_connection_pooling_postgres_example.ts index d5994342..2e1ed548 100644 --- a/examples/aws_driver_example/aws_internal_connection_pooling_postgres_example.ts +++ b/examples/aws_driver_example/aws_internal_connection_pooling_postgres_example.ts @@ -102,7 +102,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/aws_read_write_splitting_mysql_example.ts b/examples/aws_driver_example/aws_read_write_splitting_mysql_example.ts index dae4caa0..27b013b5 100644 --- a/examples/aws_driver_example/aws_read_write_splitting_mysql_example.ts +++ b/examples/aws_driver_example/aws_read_write_splitting_mysql_example.ts @@ -73,7 +73,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/aws_read_write_splitting_postgresql_example.ts b/examples/aws_driver_example/aws_read_write_splitting_postgresql_example.ts index 1c91808b..dd4a88c8 100644 --- a/examples/aws_driver_example/aws_read_write_splitting_postgresql_example.ts +++ b/examples/aws_driver_example/aws_read_write_splitting_postgresql_example.ts @@ -73,7 +73,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/fastest_response_strategy_mysql_example.ts b/examples/aws_driver_example/fastest_response_strategy_mysql_example.ts index dcbf52de..dae0c39e 100644 --- a/examples/aws_driver_example/fastest_response_strategy_mysql_example.ts +++ b/examples/aws_driver_example/fastest_response_strategy_mysql_example.ts @@ -78,7 +78,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/examples/aws_driver_example/fastest_response_strategy_postgres_example.ts b/examples/aws_driver_example/fastest_response_strategy_postgres_example.ts index 69b9d12c..7ba07d44 100644 --- a/examples/aws_driver_example/fastest_response_strategy_postgres_example.ts +++ b/examples/aws_driver_example/fastest_response_strategy_postgres_example.ts @@ -78,7 +78,7 @@ try { // https://github.com/aws/aws-advanced-nodejs-wrapper/blob/main/docs/using-the-nodejs-wrapper/using-plugins/UsingTheFailoverPlugin.md#transactionresolutionunknownerror throw error; } else { - // Unexpected exception unrelated to failover. This should be handled by the user application. + // Unexpected error unrelated to failover. This should be handled by the user application. throw error; } } finally { diff --git a/mysql/lib/dialect/mysql2_driver_dialect.ts b/mysql/lib/dialect/mysql2_driver_dialect.ts index 9dc49f53..61b9003d 100644 --- a/mysql/lib/dialect/mysql2_driver_dialect.ts +++ b/mysql/lib/dialect/mysql2_driver_dialect.ts @@ -37,7 +37,7 @@ export class MySQL2DriverDialect implements DriverDialect { async connect(hostInfo: HostInfo, props: Map): Promise { const driverProperties = WrapperProperties.removeWrapperProperties(props); - // MySQL2 does not support keep alive, explicitly check and throw an exception if this value is set to true. + // MySQL2 does not support keep alive, explicitly check and throw an error if this value is set to true. this.setKeepAliveProperties(driverProperties, props.get(WrapperProperties.KEEPALIVE_PROPERTIES.name)); this.setConnectTimeout(driverProperties, props.get(WrapperProperties.WRAPPER_CONNECT_TIMEOUT.name)); const targetClient = await createConnection(Object.fromEntries(driverProperties.entries())); diff --git a/tests/unit/aurora_connection_tracker.test.ts b/tests/unit/aurora_connection_tracker.test.ts index 0d3baa64..a14d6cf1 100644 --- a/tests/unit/aurora_connection_tracker.test.ts +++ b/tests/unit/aurora_connection_tracker.test.ts @@ -82,8 +82,8 @@ describe("aurora connection tracker tests", () => { }); it("test invalidate opened connections when writer host not changed", async () => { - const expectedException = new FailoverError(); - mockSqlFunc.mockRejectedValue(expectedException); + const expectedError = new FailoverError(); + mockSqlFunc.mockRejectedValue(expectedError); const originalHost = new HostInfoBuilder({ hostAvailabilityStrategy: new SimpleHostAvailabilityStrategy() }) .withHost("host") @@ -94,22 +94,22 @@ describe("aurora connection tracker tests", () => { const plugin = new AuroraConnectionTrackerPlugin(instance(mockPluginService), instance(mockRdsUtils), instance(mockTracker)); - await expect(plugin.execute("query", mockSqlFunc, SQL_ARGS)).rejects.toThrow(expectedException); + await expect(plugin.execute("query", mockSqlFunc, SQL_ARGS)).rejects.toThrow(expectedError); verify(mockTracker.invalidateAllConnections(originalHost)).never(); }); it("test invalidate opened connections when writer host changed", async () => { - const expectedException = new FailoverError("reason", "sqlstate"); + const expectedError = new FailoverError("reason", "sqlstate"); const originalHost = new HostInfoBuilder({ hostAvailabilityStrategy: new SimpleHostAvailabilityStrategy() }).withHost("host").build(); const failoverTargetHost = new HostInfoBuilder({ hostAvailabilityStrategy: new SimpleHostAvailabilityStrategy() }).withHost("host2").build(); when(mockPluginService.getHosts()).thenReturn([originalHost]).thenReturn([failoverTargetHost]); - mockSqlFunc.mockResolvedValueOnce("1").mockRejectedValueOnce(expectedException); + mockSqlFunc.mockResolvedValueOnce("1").mockRejectedValueOnce(expectedError); const plugin = new AuroraConnectionTrackerPlugin(instance(mockPluginService), instance(mockRdsUtils), instance(mockTracker)); await plugin.execute("query", mockSqlFunc, SQL_ARGS); - await expect(plugin.execute("query", mockSqlFunc, SQL_ARGS)).rejects.toThrow(expectedException); + await expect(plugin.execute("query", mockSqlFunc, SQL_ARGS)).rejects.toThrow(expectedError); verify(mockTracker.invalidateAllConnections(originalHost)).once(); }); }); diff --git a/tests/unit/aws_secrets_manager_plugin.test.ts b/tests/unit/aws_secrets_manager_plugin.test.ts index 35f73535..b683d66c 100644 --- a/tests/unit/aws_secrets_manager_plugin.test.ts +++ b/tests/unit/aws_secrets_manager_plugin.test.ts @@ -166,7 +166,7 @@ describe("testSecretsManager", () => { expect(TEST_PROPS.get(WrapperProperties.PASSWORD.name)).toBe(TEST_PASSWORD); }); - // The plugin will attempt to open a connection after fetching a secret, but it will fail because an exception was + // The plugin will attempt to open a connection after fetching a secret, but it will fail because an error was // thrown by the AWS Secrets Manager. it("failed to get secrets", async () => { when(mockSecretsManagerClient.send(anything())).thenThrow(secretsManagerClientException); diff --git a/tests/unit/dev_plugin.test.ts b/tests/unit/dev_plugin.test.ts index faeb7f5a..c80472c3 100644 --- a/tests/unit/dev_plugin.test.ts +++ b/tests/unit/dev_plugin.test.ts @@ -65,7 +65,7 @@ describe("testDevPlugin", () => { plugin = new DeveloperConnectionPlugin(instance(mockPluginService), properties, instance(mockRdsUtils), undefined, undefined, undefined); }); - it("testRaiseException", async () => { + it("testRaiseError", async () => { await expect(plugin.connect(hostInfo, properties, false, mockConnectFunc)).toHaveReturned; await expect(plugin.execute("query", mockFunction, [])).toHaveReturned; @@ -75,7 +75,7 @@ describe("testDevPlugin", () => { await expect(plugin.execute("query", mockFunction, [])).rejects.toEqual(TEST_ERROR); }); - it("testRaiseExceptionForMethodName", async () => { + it("testRaiseErrorForMethodName", async () => { await expect(plugin.connect(hostInfo, properties, false, mockConnectFunc)).toHaveReturned; await expect(plugin.execute("query", mockFunction, [])).toHaveReturned; @@ -85,7 +85,7 @@ describe("testDevPlugin", () => { await expect(plugin.execute("query", mockFunction, [])).rejects.toEqual(TEST_ERROR); }); - it("testRaiseExceptionForAnyMethodName", async () => { + it("testRaiseErrorForAnyMethodName", async () => { await expect(plugin.connect(hostInfo, properties, false, mockConnectFunc)).toHaveReturned; await expect(plugin.execute("query", mockFunction, [])).toHaveReturned; @@ -95,7 +95,7 @@ describe("testDevPlugin", () => { await expect(plugin.execute("query", mockFunction, [])).rejects.toEqual(TEST_ERROR); }); - it("testRaiseExceptionForWrongMethodName", async () => { + it("testRaiseErrorForWrongMethodName", async () => { await expect(plugin.connect(hostInfo, properties, false, mockConnectFunc)).toHaveReturned; await expect(plugin.execute("query", mockFunction, [])).toHaveReturned; @@ -105,7 +105,7 @@ describe("testDevPlugin", () => { await expect(plugin.execute("query", mockFunction, [])).toHaveReturned; }); - it("testRaiseExceptionWithCallback", async () => { + it("testRaiseErrorWithCallback", async () => { plugin.setCallback(instance(mockMethodCallback)); const mockArgs = ["test", "employees"]; @@ -118,7 +118,7 @@ describe("testDevPlugin", () => { await expect(plugin.execute("query", mockFunction, ["test", "admin"])).toHaveReturned; }); - it("testRaiseNoExceptionWithCallback", async () => { + it("testRaiseNoErrorWithCallback", async () => { plugin.setCallback(instance(mockMethodCallback)); const mockArgs = ["test", "employees"]; diff --git a/tests/unit/failover_plugin.test.ts b/tests/unit/failover_plugin.test.ts index 3fa1c141..4ab1d414 100644 --- a/tests/unit/failover_plugin.test.ts +++ b/tests/unit/failover_plugin.test.ts @@ -233,7 +233,7 @@ describe("reader failover handler", () => { when(mockHostInfo.allAliases).thenReturn(new Set(["alias1", "alias2"])); when(mockHostInfo.getRawAvailability()).thenReturn(HostAvailability.AVAILABLE); when(mockPluginService.getHosts()).thenReturn(hosts); - when(mockReaderResult.exception).thenReturn(test); + when(mockReaderResult.error).thenReturn(test); when(mockReaderResult.newHost).thenReturn(hostInfo); when(mockReaderFailoverHandler.failover(anything(), anything())).thenResolve(instance(mockReaderResult)); @@ -249,14 +249,14 @@ describe("reader failover handler", () => { verify(mockReaderFailoverHandlerInstance.failover(anything(), anything())); }); - it("test failover writer failed - failover throws exception", async () => { + it("test failover writer failed - failover throws error", async () => { const hostInfo = builder.withHost("hostA").build(); const hosts = [hostInfo]; const test = new AwsWrapperError("test"); when(mockHostInfo.allAliases).thenReturn(new Set(["alias1", "alias2"])); when(mockPluginService.getHosts()).thenReturn(hosts); - when(mockWriterResult.exception).thenReturn(test); + when(mockWriterResult.error).thenReturn(test); when(mockWriterFailoverHandler.failover(anything())).thenResolve(instance(mockWriterResult)); const mockHostInfoInstance = instance(mockHostInfo); diff --git a/tests/unit/host_monitoring_plugin.test.ts b/tests/unit/host_monitoring_plugin.test.ts index 6658847f..80e9839b 100644 --- a/tests/unit/host_monitoring_plugin.test.ts +++ b/tests/unit/host_monitoring_plugin.test.ts @@ -124,7 +124,7 @@ describe("host monitoring plugin test", () => { expect(queryCounter).toBe(1); }); - it("execute cleanup when checking connection status throws exception", async () => { + it("execute cleanup when checking connection status throws error", async () => { initializePlugin(); const expectedError = new AwsWrapperError("Error thrown during isClientValid"); @@ -133,7 +133,7 @@ describe("host monitoring plugin test", () => { await expect(plugin.execute(MONITOR_METHOD_NAME, incrementQueryCounter, {})).rejects.toThrow(expectedError); }); - it("execute cleanup when abort connection throws exception", async () => { + it("execute cleanup when abort connection throws error", async () => { initializePlugin(); when(mockPluginService.isClientValid(mockClientWrapper)).thenResolve(false); diff --git a/tests/unit/rds_host_list_provider.test.ts b/tests/unit/rds_host_list_provider.test.ts index 9cb8c207..bd50215e 100644 --- a/tests/unit/rds_host_list_provider.test.ts +++ b/tests/unit/rds_host_list_provider.test.ts @@ -167,7 +167,7 @@ describe("testRdsHostListProvider", () => { verify(spiedProvider.queryForTopology(anything(), anything())).atMost(1); }); - it("testQueryForTopology_queryResultsInException", async () => { + it("testQueryForTopology_queryResultsInError", async () => { const rdsHostListProvider = getRdsHostListProvider("someUrl"); when(mockDialect.queryForTopology(anything(), anything())).thenThrow(new AwsWrapperError("bad things")); diff --git a/tests/unit/writer_failover_handler.test.ts b/tests/unit/writer_failover_handler.test.ts index 998aa291..54bbe12e 100644 --- a/tests/unit/writer_failover_handler.test.ts +++ b/tests/unit/writer_failover_handler.test.ts @@ -66,7 +66,7 @@ describe("writer failover handler", () => { reset(mockReaderFailover); }); - it("test reconnect to writer - task B reader exception", async () => { + it("test reconnect to writer - task B reader error", async () => { when(mockPluginService.forceConnect(writer, anything())).thenResolve(mockClientWrapper); when(mockPluginService.forceConnect(readerA, anything())).thenThrow(new AwsWrapperError()); when(mockPluginService.forceConnect(readerB, anything())).thenThrow(new AwsWrapperError()); @@ -242,7 +242,7 @@ describe("writer failover handler", () => { clearTimeout(newWriterTimeoutId); }, 10000); - it("test failed to connect - task A exception, task B writer exception", async () => { + it("test failed to connect - task A error, task B writer error", async () => { const error = new AwsWrapperError(); when(mockPluginService.forceConnect(writer, anything())).thenThrow(error); when(mockPluginService.forceConnect(newWriterHost, anything())).thenThrow(error);