Skip to content

Commit

Permalink
chore: rename exception to error (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophia-bq authored Jan 27, 2025
1 parent 0aae47e commit d89025b
Show file tree
Hide file tree
Showing 35 changed files with 80 additions and 81 deletions.
4 changes: 2 additions & 2 deletions common/lib/authentication/aws_secrets_manager_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/lib/authentication/iam_authentication_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions common/lib/plugin_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
}
}
Expand All @@ -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.
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/lib/plugins/efm/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion common/lib/plugins/efm/monitor_connection_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
6 changes: 3 additions & 3 deletions common/lib/plugins/failover/failover_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions common/lib/plugins/failover/reader_failover_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
Expand Down
6 changes: 3 additions & 3 deletions common/lib/plugins/failover/reader_failover_result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
10 changes: 5 additions & 5 deletions common/lib/plugins/failover/writer_failover_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions common/lib/plugins/failover/writer_failover_result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion common/lib/plugins/federated_auth/federated_auth_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions common/lib/plugins/federated_auth/okta_auth_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/lib/plugins/limitless/limitless_router_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions common/lib/plugins/read_write_splitting_plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 13 additions & 14 deletions common/lib/utils/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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'",
Expand All @@ -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.",
Expand All @@ -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.",
Expand Down Expand Up @@ -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'",
Expand All @@ -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'",
Expand All @@ -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.",
Expand Down Expand Up @@ -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.",
Expand Down
Loading

0 comments on commit d89025b

Please sign in to comment.