// Syncify // // Douglas Thrift // // $Id$ #ifndef _Error_hpp_ #define _Error_hpp_ #include "menes/platform.hpp" #ifdef MENES_PRAGMA_ONCE #pragma once #endif #include #include #include struct MENES_DECLARE ApiTraits : public api::ErrorTraits { static const unsigned ErrorBase = 10; static const char* GetName() { return "SMBC"; } static ErrorCode GetLastError() { return errno; } static ext::String GetMessage(const ErrorCode& code) { char buffer[1024]; #ifdef __GNUC__ return ext::Buffer(::strerror_r(code, buffer, sizeof (buffer))); #else api::Posix::CheckError(::strerror_r(code, buffer, sizeof (buffer))); #endif return ext::Buffer(buffer); } }; MENES_DECLARE typedef api::ErrorImpl Error; _finline int CheckError(int status) { if (status < 0) throw Error(); return status; } _finline ::SMBCCTX* CheckError(::SMBCCTX* result) { if (result == NULL) throw Error(); return result; } #endif//_Error_hpp_