#include <XrdOucERoute.hh>
|
| static int | Format (char *buff, int blen, int ecode, const char *etxt1, const char *etxt2=0, const char *xtra=0) |
| static int | Route (XrdSysError *elog, XrdOucStream *estrm, const char *esfx, int ecode, const char *etxt1, const char *etxt2=0) |
Definition at line 36 of file XrdOucERoute.hh.
◆ XrdOucERoute()
| XrdOucERoute::XrdOucERoute |
( |
| ) |
|
|
inline |
◆ ~XrdOucERoute()
| XrdOucERoute::~XrdOucERoute |
( |
| ) |
|
|
inline |
◆ Format()
| int XrdOucERoute::Format |
( |
char * | buff, |
|
|
int | blen, |
|
|
int | ecode, |
|
|
const char * | etxt1, |
|
|
const char * | etxt2 = 0, |
|
|
const char * | xtra = 0 ) |
|
static |
Format an error message into a buffer in the form of: "Unable to <etxt1> <etxt2>; <syserror[enum]>"
- Parameters
-
| buff | pointer to the buffer where the msg is to be placed. |
| blen | the length of the buffer. |
| ecode | the error number associated iwth the error. |
| etxt1 | associated text token #1. |
| etxt2 | associated text token #2 (optional). |
| xtra | Optional additional text to include on the next line |
- Returns
- <int> The number of characters placed in the buffer less null.
Definition at line 44 of file XrdOucERoute.cc.
47{
49 const char *xsep = "";
50 char ebuff[256];
51 int n;
52
53
54
55 if (!estr) estr = "reason unknown";
56 else if (isupper(static_cast<int>(*estr)))
57 {
strlcpy(ebuff, estr,
sizeof(ebuff));
58 *ebuff = static_cast<char>(tolower(static_cast<int>(*estr)));
59 estr = ebuff;
60 }
61
62
63
64 if (!etxt2) etxt2 = esep = "";
65 if (xtra) xsep = "\nAdditional context: ";
66 else xtra = "";
67
68
69
70 n = snprintf(buff, blen, "Unable to %s%s%s; %s%s%s",etxt1,esep,etxt2,estr,
71 xsep, xtra);
72 return (n < blen ? n : blen-1);
73}
static const char * ec2text(int ecode)
References XrdSysError::ec2text(), and strlcpy().
Referenced by XrdOfs::Emsg(), XrdSsiUtils::Emsg(), and Route().
◆ Route()
| int XrdOucERoute::Route |
( |
XrdSysError * | elog, |
|
|
XrdOucStream * | estrm, |
|
|
const char * | esfx, |
|
|
int | ecode, |
|
|
const char * | etxt1, |
|
|
const char * | etxt2 = 0 ) |
|
static |
Format an error message using Format() and route it as requested.
- Parameters
-
| elog | pointer to the XrdSysError object to use to route the message to the log, If null, the message isn't routed there. |
| estrm | pointer to the XrdOucStrean object which is to receive the error message text or null if none exists. |
| esfx | The suffix identifier to use when routing to the log. |
| ecode | the error number associated iwth the error. |
| etxt1 | associated text token #1. |
| etxt2 | associated text token #2 (optional). |
- Returns
- <int> The -abs(enum) or -1 if enum is zero.
Definition at line 79 of file XrdOucERoute.cc.
82{
83 char ebuff[2048];
84 int elen;
85
86
87
88 elen =
Format(ebuff,
sizeof(ebuff), ecode, etxt1, etxt2);
89
90
91
92 if (elog) elog->
Emsg(esfx, ebuff);
93 if (estrm) estrm->
Put(ebuff, elen);
94
95
96
97 if (ecode) return (ecode < 0 ? ecode : -ecode);
98 return -1;
99}
static int Format(char *buff, int blen, int ecode, const char *etxt1, const char *etxt2=0, const char *xtra=0)
int Put(const char *data, const int dlen)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
References XrdSysError::Emsg(), Format(), and XrdOucStream::Put().
The documentation for this class was generated from the following files: