Detail.cc
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#include "squid.h"
10#include "error/Detail.h"
11#include "HttpRequest.h"
12#include "sbuf/SBuf.h"
13#include "sbuf/Stream.h"
14
17{
18public:
19 // convert from c-string to SBuf to simplify creation and optimize usage
21 explicit NamedErrorDetail(const char *aName): name(aName) {}
22
23 /* ErrorDetail API */
24 SBuf brief() const override { return name; }
25 SBuf verbose(const HttpRequestPointer &) const override { return name; }
26
27private:
30};
31
32/* ErrorDetail */
33
34std::ostream &
35operator <<(std::ostream &os, const ErrorDetail &detail)
36{
37 os << detail.brief();
38 return os;
39}
40
41std::ostream &
42operator <<(std::ostream &os, const ErrorDetail::Pointer &detail)
43{
44 if (detail)
45 os << *detail;
46 else
47 os << "[no details]";
48 return os;
49}
50
51/* NamedErrorDetail */
52
54MakeNamedErrorDetail(const char *name)
55{
56 return new NamedErrorDetail(name);
57}
58
ErrorDetail::Pointer MakeNamedErrorDetail(const char *name)
Definition: Detail.cc:54
std::ostream & operator<<(std::ostream &os, const ErrorDetail &detail)
dump the given ErrorDetail (for debugging)
Definition: Detail.cc:35
interface for supplying additional information about a transaction failure
Definition: Detail.h:21
virtual SBuf brief() const =0
details an error by tying it to a uniquely named circumstance
Definition: Detail.cc:17
SBuf verbose(const HttpRequestPointer &) const override
Definition: Detail.cc:25
NamedErrorDetail(const char *aName)
Definition: Detail.cc:21
SBuf name
distinguishes us from all other NamedErrorDetail objects
Definition: Detail.cc:29
SBuf brief() const override
Definition: Detail.cc:24
Definition: SBuf.h:94

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors