ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Error.hpp
Revision: 431
Committed: 2005-03-26T22:35:26-08:00 (20 years, 2 months ago) by douglas
File size: 1005 byte(s)
Log Message:
Grr! Why must this thing decided to ask for all the memory in existance at a certain point?

File Contents

# User Rev Content
1 douglas 428 // Spectre 2
2     //
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     static ext::String GetMessage(const ErrorCode& code)
27     {
28     char buffer[1024];
29    
30     #ifdef __GNUC__
31     return ext::Buffer(::strerror_r(code, buffer, sizeof (buffer)));
32     #else
33     api::Posix::CheckError(::strerror_r(code, buffer, sizeof (buffer)));
34     #endif
35    
36     return ext::Buffer(buffer);
37     }
38     };
39    
40     MENES_DECLARE typedef api::ErrorImpl<ApiTraits> Error;
41    
42     _finline int CheckError(int status)
43     {
44     if (status < 0)
45     throw Error();
46     return status;
47     }
48    
49 douglas 431 _finline ::SMBCCTX* CheckError(::SMBCCTX* result)
50     {
51     if (result == NULL)
52     throw Error();
53     return result;
54     }
55    
56 douglas 428 #endif//_Error_hpp_

Properties

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