1 |
// 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 |
#include <libsmbclient.h> |
20 |
|
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 |
|
29 |
MENES_DECLARE typedef api::ErrorImpl<ApiTraits> Error; |
30 |
|
31 |
_finline int CheckError(int status) |
32 |
{ |
33 |
if (status < 0) |
34 |
throw Error(); |
35 |
return status; |
36 |
} |
37 |
|
38 |
_finline ::SMBCCTX* CheckError(::SMBCCTX* result) |
39 |
{ |
40 |
if (result == NULL) |
41 |
throw Error(); |
42 |
return result; |
43 |
} |
44 |
|
45 |
#endif//_Error_hpp_ |