SysErrorDetail.h
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 #ifndef _SQUID_SRC_ERROR_SYSERRORDETAIL_H
10 #define _SQUID_SRC_ERROR_SYSERRORDETAIL_H
11 
12 #include "error/Detail.h"
13 #include "sbuf/SBuf.h"
14 #include "sbuf/Stream.h"
15 
18 {
20 
21 public:
24  {
25  // we could optimize by caching results for (frequently used?) errnos
26  return errorNo ? new SysErrorDetail(errorNo) : nullptr;
27  }
28 
29  static SBuf Brief(int errorNo) {
30  return SysErrorDetail(errorNo).brief();
31  }
32 
33  /* ErrorDetail API */
34  virtual SBuf brief() const override {
35  return ToSBuf("errno=", errorNo);
36  }
37 
38  virtual SBuf verbose(const HttpRequestPointer &) const override {
39  return SBuf(strerror(errorNo));
40  }
41 
42 private:
43  // hidden by NewIfAny() to avoid creating SysErrorDetail from zero errno
44  explicit SysErrorDetail(const int anErrorNo): errorNo(anErrorNo) {}
45 
46  int errorNo;
47 };
48 
49 #endif /* _SQUID_SRC_ERROR_SYSERRORDETAIL_H */
50 
int errorNo
errno(3) set by the last failed system call or equivalent
virtual SBuf verbose(const HttpRequestPointer &) const override
system call failure detail based on standard errno(3)/strerror(3) APIs
Definition: SBuf.h:87
static SBuf Brief(int errorNo)
SysErrorDetail(const int anErrorNo)
char * strerror(int ern)
Definition: strerror.c:22
static ErrorDetail::Pointer NewIfAny(const int errorNo)
MEMPROXY_CLASS(SysErrorDetail)
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf
Definition: Stream.h:63
virtual SBuf brief() const override
interface for supplying additional information about a transaction failure
Definition: Detail.h:21

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors