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

io.klerch.alexa.state.utils.AlexaStateException Maven / Gradle / Ivy

Go to download

This SDK is an extension to the Alexa Skills SDK for Java. It provides a framework for managing state of POJO models in a variety of persistence stores in an Alexa skill.

There is a newer version: 1.1.0
Show newest version
/**
 * Made by Kay Lerch (https://twitter.com/KayLerch)
 *
 * Attached license applies.
 * This library is licensed under GNU GENERAL PUBLIC LICENSE Version 3 as of 29 June 2007
 */
package io.klerch.alexa.state.utils;

import io.klerch.alexa.state.handler.AlexaStateHandler;
import io.klerch.alexa.state.model.AlexaStateModel;

public class AlexaStateException extends Exception {
    private static final long serialVersionUID = 466433664499611218L;
    private final transient AlexaStateModel model;
    private final transient AlexaStateHandler handler;

    public AlexaStateException(final AlexaStateExceptionBuilder builder) {
        super(builder.errorMessage, builder.cause);
        this.model = builder.model;
        this.handler = builder.handler != null ? builder.handler : this.model != null ? model.getHandler() : null;
    }

    public AlexaStateModel getModel() {
        return this.model;
    }

    public AlexaStateHandler getHandler() {
        return this.handler;
    }

    public static AlexaStateExceptionBuilder create(final String errorMessage) {
        return new AlexaStateExceptionBuilder(errorMessage);
    }

    public static class AlexaStateExceptionBuilder{
        AlexaStateModel model;
        AlexaStateHandler handler;
        final String errorMessage;
        Throwable cause;

        protected AlexaStateExceptionBuilder(final String errorMessage) {
            this.errorMessage = errorMessage;
        }

        public AlexaStateExceptionBuilder withModel(final AlexaStateModel model) {
            this.model = model;
            return this;
        }

        public AlexaStateExceptionBuilder withHandler(final AlexaStateHandler handler) {
            this.handler = handler;
            return this;
        }

        public AlexaStateExceptionBuilder withCause(final Throwable cause) {
            this.cause = cause;
            return this;
        }

        public AlexaStateException build() {
            return new AlexaStateException(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy