File: error.c

package info (click to toggle)
luasocket 2.0-alpha-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 452 kB
  • ctags: 437
  • sloc: ansic: 2,015; makefile: 107
file content (31 lines) | stat: -rw-r--r-- 834 bytes parent folder | download
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
#include "io.h"
#include "error.h"

/*-------------------------------------------------------------------------*\
* Translate error codes to Lua
* Input
*   err: error code to be passed to Lua
\*-------------------------------------------------------------------------*/
void error_push(lua_State *L, int err)
{
    switch (err) {
        case IO_DONE:
            lua_pushnil(L);
            break;
        case IO_TIMEOUT:
            lua_pushstring(L, "timeout");
            break;
        case IO_LIMITED:
            lua_pushstring(L, "limited");
            break;
        case IO_CLOSED:
            lua_pushstring(L, "closed");
            break;
        case IO_REFUSED:
            lua_pushstring(L, "refused");
            break;
        default:
            lua_pushstring(L, "unknown error");
            break;
    }
}