aboutsummaryrefslogtreecommitdiff
path: root/src/lua/common/je_lua_error.h
blob: bd5695df18decfcdcecdd7c2f0ea45c6edf3ee80 (plain)
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
#ifndef __JIN_ERROR_H
#define __JIN_ERROR_H

#include <string.h>

#include "common/je_lua.h"

namespace JinEngine
{
    namespace Lua
    {

        static const int FORMAT_MSG_BUFFER_SIZE = 2048;

        inline void error(lua_State* L, const char* fmt, ...)
        {
            char err[FORMAT_MSG_BUFFER_SIZE + 1] = { 0 };
            va_list args;
            va_start(args, fmt);
            vsnprintf(err + strlen(err), FORMAT_MSG_BUFFER_SIZE, fmt, args);
            va_end(args);
            //luax_getglobal(L, "jin");
            //luax_setfieldstring(L, "error", err);
            luax_error(L, err);
        }

    } // namespace Lua
} // namespace JinEngine 

#endif