1 #ifndef CTRANSITION___NCBIERR__HPP 2 #define CTRANSITION___NCBIERR__HPP 3 4 /* $Id: ncbierr.hpp 550813 2017-11-08 12:52:45Z ivanov $ 5 * =========================================================================== 6 * 7 * PUBLIC DOMAIN NOTICE 8 * National Center for Biotechnology Information 9 * 10 * This software/database is a "United States Government Work" under the 11 * terms of the United States Copyright Act. It was written as part of 12 * the author's official duties as a United States Government employee and 13 * thus cannot be copyrighted. This software/database is freely available 14 * to the public for use. The National Library of Medicine and the U.S. 15 * Government have not placed any restriction on its use or reproduction. 16 * 17 * Although all reasonable efforts have been taken to ensure the accuracy 18 * and reliability of the software and data, the NLM and the U.S. 19 * Government do not and cannot warrant the performance or results that 20 * may be obtained by using this software or data. The NLM and the U.S. 21 * Government disclaim all warranties, express or implied, including 22 * warranties of performance, merchantability or fitness for any particular 23 * purpose. 24 * 25 * Please cite the author in any work or product based on this material. 26 * 27 * =========================================================================== 28 * 29 * Author: Vladimir Ivanov 30 * Wrapper for the C Toolkit ErrPostEx() macro. 31 * 32 */ 33 34 /** @addtogroup CToolsBridge 35 * 36 * @{ 37 */ 38 39 40 #include <corelib/ncbidiag.hpp> 41 #include <ctools/ctransition/ncbilcl.hpp> 42 43 BEGIN_CTRANSITION_SCOPE 44 45 46 // C Toolkit error codes 47 48 #define E_NoMemory 1 49 #define E_Programmer 999 50 51 /* 52 #define E_File 2 53 #define E_FOpen 3 54 #define E_FRead 4 55 #define E_FWrite 5 56 #define E_CdEject 9 57 #define E_Math 4 58 #define E_SGML 3 59 */ 60 61 62 // C Toolkit severity 63 enum ErrSev { SEV_NONE=0, SEV_INFO, SEV_WARNING, SEV_ERROR, SEV_REJECT, SEV_FATAL, SEV_MAX }; 64 // ? 65 #define MSG_OK SEV_ERROR 66 67 // C -> C++ names conversion 68 #define ErrPostStr ErrPostEx 69 #define ErrSetLog SetLogFile 70 71 // Convert C Toolkit severity to C++ 72 extern NCBI_NS_NCBI::Severity ctransition_ErrSeverity(ErrSev sev); 73 74 // Convert variable list of arguments to string 75 extern std::string ctransition_ErrMessage(const char* format, ...); 76 77 // Post message 78 #define ErrPostEx(sev, err_code, ...) \ 79 ( NCBI_NS_NCBI::CNcbiDiag(DIAG_COMPILE_INFO).GetRef() \ 80 << NCBI_NS_NCBI::ErrCode(err_code) \ 81 << ctransition_ErrSeverity(sev) \ 82 << ctransition_ErrMessage(__VA_ARGS__) \ 83 << NCBI_NS_NCBI::Endm ) 84 85 86 // Redefine message function via ErrPostEx() 87 #define Nlm_Message(key, ...) ErrPostEx((ErrSev)key, 0, __VA_ARGS__) 88 89 90 END_CTRANSITION_SCOPE 91 92 /* @} */ 93 94 #endif /* CTRANSITION___NCBIERR__HPP */ 95