-
Notifications
You must be signed in to change notification settings - Fork 52
/
error.h
35 lines (26 loc) · 867 Bytes
/
error.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2010, Camilo Aguilar. Cloudescape, LLC.
#ifndef ERROR_H
#define ERROR_H
#include "node_libvirt.h"
namespace NLV {
class Error : public Nan::ObjectWrap
{
public:
static void Initialize(Handle<Object> exports);
static Local<Value> New(virErrorPtr error, std::string context);
private:
explicit Error(virErrorPtr error, std::string context);
~Error();
static Nan::Persistent<Function> constructor;
static NAN_GETTER(Getter);
virErrorPtr error_;
std::string context_;
};
} //namespace NLV
#define _LIBVIRT_STRINGIZE_DETAIL(x) #x
#define _LIBVIRT_STRINGIZE(x) _LIBVIRT_STRINGIZE_DETAIL(x)
#define ThrowLastVirError() \
Nan::ThrowError(Error::New(virSaveLastError(), __FILE__ ":" _LIBVIRT_STRINGIZE(__LINE__)))
#define SET_ERROR_WITH_CONTEXT(error) \
SetVirError(error, __FILE__ ":" _LIBVIRT_STRINGIZE(__LINE__))
#endif // ERROR_H