1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #913, coroutine support complex error.

This commit is contained in:
winlin 2017-06-11 18:44:20 +08:00
parent 9ae54850bf
commit 9db2a04c3b
38 changed files with 620 additions and 414 deletions

View file

@ -41,8 +41,7 @@ bool srs_is_client_gracefully_close(int error_code)
{
return error_code == ERROR_SOCKET_READ
|| error_code == ERROR_SOCKET_READ_FULLY
|| error_code == ERROR_SOCKET_WRITE
|| error_code == ERROR_SOCKET_TIMEOUT;
|| error_code == ERROR_SOCKET_WRITE;
}
SrsError::SrsError()
@ -137,6 +136,27 @@ SrsError* SrsError::success() {
return NULL;
}
SrsError* SrsError::copy(SrsError* from)
{
if (from == srs_success) {
return srs_success;
}
SrsError* err = new SrsError();
err->code = from->code;
err->wrapped = srs_error_copy(from->wrapped);
err->msg = from->msg;
err->func = from->func;
err->file = from->file;
err->line = from->line;
err->cid = from->cid;
err->rerrno = from->rerrno;
err->desc = from->desc;
return err;
}
string SrsError::description(SrsError* err)
{
return err? err->description() : "Success";

View file

@ -330,6 +330,7 @@
/**
* whether the error code is an system control error.
*/
// TODO: FIXME: Remove it from underlayer for confused with error and logger.
extern bool srs_is_system_control_error(int error_code);
extern bool srs_is_client_gracefully_close(int error_code);
@ -359,6 +360,7 @@ public:
static SrsError* create(const char* func, const char* file, int line, int code, const char* fmt, ...);
static SrsError* wrap(const char* func, const char* file, int line, SrsError* err, const char* fmt, ...);
static SrsError* success();
static SrsError* copy(SrsError* from);
static std::string description(SrsError* err);
static int error_code(SrsError* err);
};
@ -367,6 +369,7 @@ public:
#define srs_success SrsError::success()
#define srs_error_new(ret, fmt, ...) SrsError::create(__FUNCTION__, __FILE__, __LINE__, ret, fmt, ##__VA_ARGS__)
#define srs_error_wrap(err, fmt, ...) SrsError::wrap(__FUNCTION__, __FILE__, __LINE__, err, fmt, ##__VA_ARGS__)
#define srs_error_copy(err) SrsError::copy(err)
#define srs_error_desc(err) SrsError::description(err)
#define srs_error_code(err) SrsError::error_code(err)