Comments (3)
TODO: look into updating libuv dependency version
from node.native.
I've been looking at this. I think the error class gets simpler because there are fewer types to handle.
I've drafted out error.h as:
#ifndef __ERROR_H__
#define __ERROR_H__
#include "base.h"
namespace native
{
class exception
{
public:
exception(const std::string& message)
: message_(message)
{}
virtual ~exception() {}
const std::string& message() const { return message_; }
private:
std::string message_;
};
class error
{
public:
error() : uv_err_(0) {}
error(int e) : uv_err_(e) {}
~error() = default;
public:
operator bool() { return uv_err_ != 0; } // Is 0 the right number for no error in UV?
int code() const { return uv_err_; }
const char* name() const { return uv_err_name(uv_err_); }
const char* str() const { return uv_strerror(uv_err_); }
private:
int uv_err_;
};
// uv no longer has uv_last_error. Instead use return from the uv call.
//error get_last_error() { return uv_last_error(uv_default_loop()); }
}
#endif
But I don't know how to modify the calling code, such as tcp.h, fs.h and so on. Any hints from the original coder?
from node.native.
For example, here's a call to uv_tcp_connect from tcp.h:
bool connect(const std::string& ip, int port, std::function<void(error)> callback)
{
callbacks::store(get()->data, native::internal::uv_cid_connect, callback);
return uv_tcp_connect(new uv_connect_t, get<uv_tcp_t>(), to_ip4_addr(ip, port), [](uv_connect_t* req, int status) {
callbacks::invoke<decltype(callback)>(req->handle->data, native::internal::uv_cid_connect, status?uv_last_error(req->handle->loop):error());
delete req;
}) == 0;
}
Previously you had to call uv_last_error to get the last error code, if any. Now, uv_tcp_connect returns the error directly, as an int. So what about the handling of "status" in the callback? I can't see how to do the right thing here.
from node.native.
Related Issues (20)
- Guide for newbie?
- compiler error under mac os x
- returning reference to local temporary object HOT 2
- fstat missing, actually path exists thats what i need HOT 3
- Build System HOT 4
- roadmap and next milestones HOT 34
- SEGV on multiple semi-parallel clients. HOT 3
- Segmentation fault when concurrent requests arrives. HOT 7
- Keep-Alive support HOT 3
- URL routing? HOT 3
- CMakeLists in node.native + seperate project? HOT 2
- node.native CMakeLists.txt replacement for its Makefile? HOT 2
- serve/stream static file(s)
- I can't compile node.native HOT 2
- How to get HTTP verb? (GET, POST, PUT, HEAD, PATCH) HOT 4
- Include in multiple files of a large application
- this project still active? :( HOT 6
- what's the meaning of this project?
- R.I.P HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node.native.