Permalink
Browse files

[error reporting] refactored exception handling

  • Loading branch information...
1 parent 34641a3 commit fa56ea63f5b2a4b13dafe5c34bce182189b4a627 @agnat committed Dec 28, 2012
View
2 src/dns_service_browse.cpp
@@ -92,7 +92,7 @@ DNSServiceBrowse(Arguments const& args) {
OnServiceChanged, serviceRef);
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceBrowse()", error);
+ return throwMdnsError(error);
}
if ( ! serviceRef->SetSocketFlags()) {
View
2 src/dns_service_enumerate_domains.cpp
@@ -65,7 +65,7 @@ DNSServiceEnumerateDomains(Arguments const& args) {
flags, interfaceIndex, OnEnumeration, serviceRef);
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceEnumerateDomains()", error);
+ return throwMdnsError(error);
}
if ( ! serviceRef->SetSocketFlags()) {
return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)");
View
2 src/dns_service_get_addr_info.cpp
@@ -117,7 +117,7 @@ DNSServiceGetAddrInfo(Arguments const& args) {
flags, interfaceIndex, protocol, *hostname, OnAddressInfo, serviceRef);
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceGetAddrInfo()", error);
+ return throwMdnsError(error);
}
if ( ! serviceRef->SetSocketFlags()) {
return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)");
View
2 src/dns_service_process_result.cpp
@@ -24,7 +24,7 @@ DNSServiceProcessResult(Arguments const& args) {
ref->SetThis(args.This());
DNSServiceErrorType error = DNSServiceProcessResult(ref->GetServiceRef());
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceProcessResult()", error);
+ return throwMdnsError(error);
}
return Undefined();
}
View
2 src/dns_service_register.cpp
@@ -157,7 +157,7 @@ DNSServiceRegister(Arguments const& args) {
args[9]->IsFunction() ? OnServiceRegistered : NULL,
serviceRef);
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceRegister()", error);
+ return throwMdnsError(error);
}
if ( ! serviceRef->SetSocketFlags()) {
return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)");
View
2 src/dns_service_resolve.cpp
@@ -105,7 +105,7 @@ DNSServiceResolve(Arguments const& args) {
flags, interfaceIndex, *name, *serviceType, *domain, OnResolve, serviceRef);
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("DNSServiceResolve()", error);
+ return throwMdnsError(error);
}
if ( ! serviceRef->SetSocketFlags()) {
return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)");
View
12 src/mdns_utils.hpp
@@ -23,17 +23,9 @@ throwTypeError(const char * message) {
}
inline
-v8::Local<v8::Value>
-mdnsError(const char * message, DNSServiceErrorType error_code) {
- v8::Local<v8::String> str1 = v8::String::Concat( v8::String::New(message), v8::String::NewSymbol(": "));
- v8::Local<v8::String> str2 = v8::String::Concat(str1, v8::String::New(errorString(error_code)));
- return v8::Local<v8::Object>::Cast( v8::Exception::Error( str2 ));
-}
-
-inline
v8::Handle<v8::Value>
-throwMdnsError(const char * message, DNSServiceErrorType error_code) {
- return ThrowException(mdnsError(message, error_code));
+throwMdnsError(DNSServiceErrorType error_code) {
+ return ThrowException(buildException(error_code));
}
inline
View
2 src/txt_record_buffer_to_object.cpp
@@ -39,7 +39,7 @@ txtRecordBufferToObject(Arguments const& args) {
key.resize(key.size() * 2);
}
if (error != kDNSServiceErr_NoError) {
- return throwMdnsError("TXTRecordGetItemAtIndex", error);
+ return throwMdnsError(error);
}
result->Set(String::New(&*key.begin()),
value_ptr ?
View
2 src/txt_record_set_value.cpp
@@ -46,7 +46,7 @@ TXTRecordSetValue(Arguments const& args) {
? NULL : args[2]->IsString() ? *String::Utf8Value(args[2]->ToString()) : Buffer::Data(args[2]->ToObject())));
if (code != kDNSServiceErr_NoError) {
- return throwMdnsError("failed to set txt record value", code);
+ return throwMdnsError(code);
}
return Undefined();
}

0 comments on commit fa56ea6

Please sign in to comment.