NCBI C++ ToolKit
ct_ncbierr.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: ct_ncbierr.cpp 99259 2023-03-03 14:19:46Z ivanov $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Vladimir Ivanov
27  *
28  * File Description:
29  * Wrapper for the C Toolkit ErrPostEx() macro.
30  *
31  */
32 
33 
34 #include <ncbi_pch.hpp>
35 #include <corelib/ncbidbg.hpp>
37 #include <stdio.h>
38 #include <stdarg.h>
39 
42 
43 
45 {
46  EDiagSev cxx_severity;
47  switch (c_severity) {
48  case SEV_NONE:
49  cxx_severity = eDiag_Trace;
50  break;
51  case SEV_INFO:
52  cxx_severity = eDiag_Info;
53  break;
54  case SEV_WARNING:
55  cxx_severity = eDiag_Warning;
56  break;
57  case SEV_ERROR:
58  cxx_severity = eDiag_Error;
59  break;
60  case SEV_REJECT:
61  cxx_severity = eDiag_Critical;
62  break;
63  case SEV_FATAL:
64  default:
65  cxx_severity = eDiag_Fatal;
66  break;
67  }
68  return cxx_severity;
69 }
70 
71 
72 string ctransition_ErrMessage(const char* format, ...)
73 {
74  const int kMax = 8*1024;
75  char buffer[kMax];
76  va_list args;
77  va_start(args, format);
78  int n = vsnprintf(buffer, kMax, format, args);
79  if (n < 0 || n >= kMax) {
80  _TROUBLE;
81  }
82  va_end(args);
83  return string(buffer);
84 }
85 
86 
Severity –.
Definition: ncbidiag.hpp:833
USING_NCBI_SCOPE
Definition: ct_ncbierr.cpp:40
#define SEV_INFO
Definition: gicache.c:89
#define SEV_WARNING
Definition: gicache.c:90
#define SEV_ERROR
Definition: gicache.c:91
#define SEV_NONE
Definition: gicache.c:88
#define SEV_FATAL
Definition: gicache.c:93
#define SEV_REJECT
Definition: gicache.c:92
string
Definition: cgiapp.hpp:687
#define BEGIN_CTRANSITION_SCOPE
Definition: ncbilcl.hpp:49
string ctransition_ErrMessage(const char *format,...)
Definition: ct_ncbierr.cpp:72
BEGIN_CTRANSITION_SCOPE Severity ctransition_ErrSeverity(ErrSev c_severity)
Definition: ct_ncbierr.cpp:44
#define END_CTRANSITION_SCOPE
Definition: ncbilcl.hpp:50
ErrSev
Definition: ncbierr.hpp:63
EDiagSev
Severity level for the posted diagnostics.
Definition: ncbidiag.hpp:650
@ eDiag_Trace
Trace message.
Definition: ncbidiag.hpp:657
@ eDiag_Info
Informational message.
Definition: ncbidiag.hpp:651
@ eDiag_Error
Error message.
Definition: ncbidiag.hpp:653
@ eDiag_Warning
Warning message.
Definition: ncbidiag.hpp:652
@ eDiag_Fatal
Fatal error – guarantees exit(or abort)
Definition: ncbidiag.hpp:655
@ eDiag_Critical
Critical error message.
Definition: ncbidiag.hpp:654
yy_size_t n
#define vsnprintf
Definition: ncbiconf_msvc.h:66
NCBI C++ auxiliary debug macros.
static Format format
Definition: njn_ioutil.cpp:53
static pcre_uint8 * buffer
Definition: pcretest.c:1051
static const string kMax
Definition: showdefline.cpp:95
#define _TROUBLE
Modified on Tue May 28 05:50:58 2024 by modify_doxy.py rev. 669887