Interface ConnectorErrorHelper


  • public interface ConnectorErrorHelper
    Provides 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 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 a ConnectorException instance.
        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 of ConnectorResponse, without rethrowing the exception.
        Parameters:
        action - any action returning a ConnectorResponse
        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 of ConnectorResponse, without rethrowing the exception.
        Parameters:
        action - any action returning a ConnectorResponse
        Returns:
        Response returned by the supplier or caught, logged and wrapped exception
      • buildDefault

        static ConnectorErrorHelper buildDefault​(Session session,
                                                 String scopeName)
        Builds a default instance of the ConnectorErrorHelper.

        Default implementation of the helper uses:

        Parameters:
        session - Snowpark session object
        scopeName - name for the scope of the event table log entry
        Returns:
        a new error helper instance