// ----------------------------------------------------------------------
// File: ErrorModel.hh
// Author: Cedric Caffy - CERN
// ----------------------------------------------------------------------
/************************************************************************
* EOS - the CERN Disk Storage System *
* Copyright (C) 2013 CERN/Switzerland *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see .*
************************************************************************/
#ifndef EOS_ERRORMODEL_HH
#define EOS_ERRORMODEL_HH
#include "mgm/Namespace.hh"
#include
#include
#include
#include
#include
#include "common/json/Jsonifiable.hh"
EOSMGMRESTNAMESPACE_BEGIN
/**
* This class represents the Error object that will be returned to the client
* if an error occured. It follows the RFC 7807 https://datatracker.ietf.org/doc/html/rfc7807
*/
class ErrorModel : public common::Jsonifiable
{
public:
ErrorModel();
ErrorModel(const std::string& title, const uint32_t status,
const std::optional& detail);
ErrorModel(const std::string& title, const uint32_t status);
void setType(const std::string& type);
void setTitle(const std::string& title);
void setStatus(const uint32_t status);
void setDetail(const std::string& detail);
const std::optional getType() const;
const std::string getTitle() const;
const uint32_t getStatus() const;
const std::optional getDetail() const;
virtual ~ErrorModel() {}
private:
/**
* A URI reference that identifies the problem type This specification encourages that, when dereferenced,
* it provide human-readable documentation for the problem type (e.g., using HTML).
*/
std::optional mType;
/**
* A short, human-readable summary of the problem type
*/
std::string mTitle;
/**
* The HTTP status code generated by the origin server for this occurrence of the problem.
*/
uint32_t mStatus;
/**
* A human-readable explanation specific to this occurrence of the problem.
*/
std::optional mDetail;
};
EOSMGMRESTNAMESPACE_END
#endif // EOS_ERRORMODEL_HH