package com.vaessl.app.exception;

import org.springframework.http.HttpStatus;

import com.fasterxml.jackson.annotation.JsonValue;

public enum ErrorMessage {
    BAD_REQUEST_EMPTY_FIELDS(HttpStatus.BAD_REQUEST,
            "Fields must not be empty."), UNAUTHORIZED_WRONG_LOGIN(HttpStatus.UNAUTHORIZED,
                    "Invalid username or password."), SERVICE_UNAVAILABLE_UNREACHABLE_URL(
                            HttpStatus.SERVICE_UNAVAILABLE,
                            "The target URL is unreachable."), SERVER_ERROR_GENERAL(
                                    "The external app returned a server error: "), WRONG_SERVICE_TYPE(
                                            HttpStatus.NOT_FOUND,
                                            "No such service type."), CONNECTION_NOT_FOUND(
                                                    HttpStatus.NOT_FOUND,
                                                    "No active connection found for this service."), REMOTE_API_EMPTY_RESPONSE(
                                                            HttpStatus.BAD_GATEWAY,
                                                            "Remote API returned empty response for "), REMOTE_API_CLIENT_ERROR(
                                                                    HttpStatus.BAD_GATEWAY,
                                                                    "Remote API returned an unexpected error: ");

    private final HttpStatus status;
    private final String message;

    private ErrorMessage(HttpStatus status, String message) {
        this.status = status;
        this.message = message;
    }

    private ErrorMessage(String message) {
        this.status = null;
        this.message = message;
    }

    public HttpStatus getStatus() {
        return status;
    }

    @JsonValue
    public String getMessage() {
        return message;
    }
}
