ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/Spectre2/Error.hpp
Revision: 428
Committed: 2005-03-24T17:38:00-08:00 (20 years, 2 months ago) by douglas
File size: 870 byte(s)
Log Message:
Finally, I can commit!

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    
20     struct MENES_DECLARE ApiTraits : public api::ErrorTraits<int>
21     {
22     static const unsigned ErrorBase = 10;
23     static const char* GetName() { return "SMBC"; }
24     static ErrorCode GetLastError() { return errno; }
25     static ext::String GetMessage(const ErrorCode& code)
26     {
27     char buffer[1024];
28    
29     #ifdef __GNUC__
30     return ext::Buffer(::strerror_r(code, buffer, sizeof (buffer)));
31     #else
32     api::Posix::CheckError(::strerror_r(code, buffer, sizeof (buffer)));
33     #endif
34    
35     return ext::Buffer(buffer);
36     }
37     };
38    
39     MENES_DECLARE typedef api::ErrorImpl<ApiTraits> Error;
40    
41     _finline int CheckError(int status)
42     {
43     if (status < 0)
44     throw Error();
45     return status;
46     }
47    
48     #endif//_Error_hpp_

Properties

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