All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.odpi.openmetadata.governanceservers.openlineage.util.OpenLineageExceptionHandler Maven / Gradle / Ivy

Go to download

Provides the definitions that make up the APIs used by external components when communicating with the open lineage.

There is a newer version: 4.3
Show newest version
/* SPDX-License-Identifier: Apache-2.0 */
package org.odpi.openmetadata.governanceservers.openlineage.util;

import org.odpi.openmetadata.commonservices.ffdc.RESTExceptionHandler;
import org.odpi.openmetadata.commonservices.ffdc.rest.FFDCResponseBase;
import org.odpi.openmetadata.governanceservers.openlineage.ffdc.OpenLineageException;

public class OpenLineageExceptionHandler extends RESTExceptionHandler {

    public void captureOpenLineageException(FFDCResponseBase response, OpenLineageException e) {
        response.setRelatedHTTPCode(e.getReportedHTTPCode());
        response.setExceptionClassName(e.getClass().getName());
        response.setExceptionErrorMessage(e.getErrorMessage());
        response.setExceptionSystemAction(e.getReportedSystemAction());
        response.setExceptionUserAction(e.getReportedUserAction());
    }

    /**
     * Throw an detectAndThrowOpenLineageException if it is encoded in the REST response.
     *
     * @param methodName name of the method called
     * @param restResult response from the rest call.  This generated in the remote server.
     * @throws OpenLineageException encoded exception from the server
     */
    public void detectAndThrowOpenLineageException(String methodName,
                                                   FFDCResponseBase restResult) throws OpenLineageException {
        final String exceptionClassName = OpenLineageException.class.getName();

        if ((restResult != null) && (exceptionClassName.equals(restResult.getExceptionClassName()))) {
            throw new OpenLineageException(restResult.getRelatedHTTPCode(),
                    this.getClass().getName(),
                    methodName,
                    restResult.getExceptionErrorMessage(),
                    restResult.getExceptionSystemAction(),
                    restResult.getExceptionUserAction());
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy