ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Syncify/Error.hpp
Revision: 440
Committed: 2005-04-07T22:53:00-07:00 (20 years, 2 months ago) by douglas
File size: 1050 byte(s)
Log Message:
Worky!

File Contents

# User Rev Content
1 douglas 436 // Syncify
2 douglas 428 //
3     // Douglas Thrift
4     //
5     // $Id$
6    
7     #ifndef _Error_hpp_
8     #define _Error_hpp_
9    
10     #include "menes/platform.hpp"
11    
12     #ifdef MENES_PRAGMA_ONCE
13     #pragma once
14     #endif
15    
16     #include <menes-api/error.hpp>
17    
18     #include <errno.h>
19 douglas 431 #include <libsmbclient.h>
20 douglas 428
21     struct MENES_DECLARE ApiTraits : public api::ErrorTraits<int>
22     {
23     static const unsigned ErrorBase = 10;
24     static const char* GetName() { return "SMBC"; }
25     static ErrorCode GetLastError() { return errno; }
26 douglas 440 // XXX: doesn't actually give anything useful
27 douglas 428 static ext::String GetMessage(const ErrorCode& code)
28     {
29     char buffer[1024];
30    
31     #ifdef __GNUC__
32     return ext::Buffer(::strerror_r(code, buffer, sizeof (buffer)));
33     #else
34     api::Posix::CheckError(::strerror_r(code, buffer, sizeof (buffer)));
35     #endif
36    
37     return ext::Buffer(buffer);
38     }
39     };
40    
41     MENES_DECLARE typedef api::ErrorImpl<ApiTraits> Error;
42    
43     _finline int CheckError(int status)
44     {
45     if (status < 0)
46     throw Error();
47     return status;
48     }
49    
50 douglas 431 _finline ::SMBCCTX* CheckError(::SMBCCTX* result)
51     {
52     if (result == NULL)
53     throw Error();
54     return result;
55     }
56    
57 douglas 428 #endif//_Error_hpp_

Properties

Name Value
svn:eol-style native
svn:keywords Id