// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.providerhub.models;

import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** Standard error object. */
@Immutable
public class Error {
    /*
     * Server-defined set of error codes.
     */
    @JsonProperty(value = "code", access = JsonProperty.Access.WRITE_ONLY)
    private String code;

    /*
     * Human-readable representation of the error.
     */
    @JsonProperty(value = "message", access = JsonProperty.Access.WRITE_ONLY)
    private String message;

    /*
     * Target of the error.
     */
    @JsonProperty(value = "target", access = JsonProperty.Access.WRITE_ONLY)
    private String target;

    /*
     * Array of details about specific errors that led to this reported error.
     */
    @JsonProperty(value = "details", access = JsonProperty.Access.WRITE_ONLY)
    private List<Error> details;

    /*
     * Object containing more specific information than  the current object about the error.
     */
    @JsonProperty(value = "innerError", access = JsonProperty.Access.WRITE_ONLY)
    private ErrorInnerError innerError;

    /** Creates an instance of Error class. */
    public Error() {
    }

    /**
     * Get the code property: Server-defined set of error codes.
     *
     * @return the code value.
     */
    public String code() {
        return this.code;
    }

    /**
     * Get the message property: Human-readable representation of the error.
     *
     * @return the message value.
     */
    public String message() {
        return this.message;
    }

    /**
     * Get the target property: Target of the error.
     *
     * @return the target value.
     */
    public String target() {
        return this.target;
    }

    /**
     * Get the details property: Array of details about specific errors that led to this reported error.
     *
     * @return the details value.
     */
    public List<Error> details() {
        return this.details;
    }

    /**
     * Get the innerError property: Object containing more specific information than the current object about the error.
     *
     * @return the innerError value.
     */
    public ErrorInnerError innerError() {
        return this.innerError;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (details() != null) {
            details().forEach(e -> e.validate());
        }
        if (innerError() != null) {
            innerError().validate();
        }
    }
}
