package com.rera.mss.exceptions

import org.springframework.http.ResponseEntity

class ErrorDtoResponseEntityBuilder(
        private val error: ExceptionType
) {

    private var message: String? = null
    private var detail: Any? = null

    fun withMessage(message: String?): ErrorDtoResponseEntityBuilder {
        this.message = message
        return this
    }

    fun withDetail(detail: Any?): ErrorDtoResponseEntityBuilder {
        this.detail = detail
        return this
    }

    fun buildResponseEntity(): ResponseEntity<ErrorDto> {
        return ResponseEntity(
                ErrorDto(
                        error,
                        error.statusCode.value(),
                        message,
                        detail
                ),
                error.statusCode
        )
    }
}