Detail.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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 {
18 public:
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  virtual SBuf brief() const override { return name; }
25  virtual SBuf verbose(const HttpRequestPointer &) const override { return name; }
26 
27 private:
30 };
31 
32 /* ErrorDetail */
33 
34 std::ostream &
35 operator <<(std::ostream &os, const ErrorDetail &detail)
36 {
37  os << detail.brief();
38  return os;
39 }
40 
41 std::ostream &
42 operator <<(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 
54 MakeNamedErrorDetail(const char *name)
55 {
56  return new NamedErrorDetail(name);
57 }
58 
SBuf name
distinguishes us from all other NamedErrorDetail objects
Definition: Detail.cc:29
NamedErrorDetail(const char *aName)
Definition: Detail.cc:21
Definition: SBuf.h:87
details an error by tying it to a uniquely named circumstance
Definition: Detail.cc:17
virtual SBuf brief() const override
Definition: Detail.cc:24
virtual SBuf brief() const =0
virtual SBuf verbose(const HttpRequestPointer &) const override
Definition: Detail.cc:25
interface for supplying additional information about a transaction failure
Definition: Detail.h:21
std::ostream & operator<<(std::ostream &os, const ErrorDetail &detail)
dump the given ErrorDetail (for debugging)
Definition: Detail.cc:35
ErrorDetail::Pointer MakeNamedErrorDetail(const char *name)
Definition: Detail.cc:54

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors