Interface ConnectorErrorHelper
-
public interface ConnectorErrorHelperProvides utility methods for catching, logging and mapping exceptions within the connector. The purpose of this helper is to abstract away repetitive try-catch blocks and provide a central point for exception logging and mapping.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static ConnectorErrorHelperbuildDefault(Session session, String scopeName)Builds a default instance of theConnectorErrorHelper.static ConnectorErrorHelperBuilderbuilder(Session session, String scopeName)Returns a new instance ofConnectorErrorHelperBuilder.<T> TwithExceptionLogging(Supplier<T> action)Wraps the provided action in a try/catch block, and if any exception is caught - logs it and maps it to aConnectorExceptioninstance.default ConnectorResponsewithExceptionLoggingAndWrapping(Supplier<ConnectorResponse> action)Wraps the provided action in a try/catch block, and if any exception is caught - logs it and returns it as an instance ofConnectorResponse, without rethrowing the exception.ConnectorResponsewithExceptionWrapping(Supplier<ConnectorResponse> action)Wraps the provided action in a try/catch block, and if any exception is caught - returns it as an instance ofConnectorResponse, without rethrowing the exception.
-
-
-
Method Detail
-
withExceptionLogging
<T> T withExceptionLogging(Supplier<T> action) throws ConnectorException
Wraps the provided action in a try/catch block, and if any exception is caught - logs it and maps it to aConnectorExceptioninstance.- Type Parameters:
T- type of the result of the action- Parameters:
action- action to execute- Returns:
- the result of the action
- Throws:
ConnectorException- caught, logged and rethrown exception
-
withExceptionWrapping
ConnectorResponse withExceptionWrapping(Supplier<ConnectorResponse> action)
Wraps the provided action in a try/catch block, and if any exception is caught - returns it as an instance ofConnectorResponse, without rethrowing the exception.- Parameters:
action- any action returning aConnectorResponse- Returns:
- Response returned by the supplier or caught and wrapped exception
-
withExceptionLoggingAndWrapping
default ConnectorResponse withExceptionLoggingAndWrapping(Supplier<ConnectorResponse> action)
Wraps the provided action in a try/catch block, and if any exception is caught - logs it and returns it as an instance ofConnectorResponse, without rethrowing the exception.- Parameters:
action- any action returning aConnectorResponse- Returns:
- Response returned by the supplier or caught, logged and wrapped exception
-
builder
static ConnectorErrorHelperBuilder builder(Session session, String scopeName)
Returns a new instance ofConnectorErrorHelperBuilder.- Parameters:
session- Snowpark session objectscopeName- name for the scope of the event table log entry- Returns:
- a new builder instance
-
buildDefault
static ConnectorErrorHelper buildDefault(Session session, String scopeName)
Builds a default instance of theConnectorErrorHelper.Default implementation of the helper uses:
- a default implementation of
ExceptionMapper - a default implementation of
ExceptionLogger
- Parameters:
session- Snowpark session objectscopeName- name for the scope of the event table log entry- Returns:
- a new error helper instance
- a default implementation of
-
-