BeepBeep 和 ErlyDB 集成问题

发布于 2024-07-30 08:37:59 字数 1023 浏览 2 评论 0原文

继续我与 Erlang 和 ErlyDB 的冒险。 我正在尝试让 ErlyDB 与 BeepBeep 一起使用

我的 ErlyDB 设置在 BeepBeep 环境之外运行时可以正常工作(请参阅调试 ErlyDB 和 MySQL)。 我基本上已经获取了工作代码并尝试让它在 BeepBeep 中运行。

我的控制器中有以下代码:

handle_request("index",[]) ->
  erlydb:start(mysql,Database),
  erlydb:code_gen(["thing.erl"],mysql), 
  NewThing = thing:new_with([{name, "name"},{value, "value"}]),
  thing:save(NewThing),
  {render,"home/index.html",[{data,"Hello World!"}]};

当我调用 URL 时,响应输出“服务器错误”。 没有报告其他错误或异常信息。

我尝试将调用包装在 try/catch 中以查看是否存在潜在错误 - 对 thing:new_with() 的调用肯定存在异常,但没有进一步的信息可用。

堆栈跟踪报告:

{thing,new,[["name","value"]]}
{home_controller,create,1}
{home_controller,handle_request,3}
{beepbeep,process_request,4}
{test_web,loop,1}
{mochiweb_http,headers,4}
{proc_lib,init_p_do_apply,3}

Further to my adventures with Erlang and ErlyDB. I am attempting to get ErlyDB working with BeepBeep

My ErlyDB setup works correctly when run outside of the BeepBeep environment (see Debugging ErlyDB and MySQL). I have basically take the working code and attempted to get it running inside BeepBeep.

I have the following code in my controller:

handle_request("index",[]) ->
  erlydb:start(mysql,Database),
  erlydb:code_gen(["thing.erl"],mysql), 
  NewThing = thing:new_with([{name, "name"},{value, "value"}]),
  thing:save(NewThing),
  {render,"home/index.html",[{data,"Hello World!"}]};

When I call the URL, the response outputs "Server Error".
There is no other error or exception information reported.

I have tried wrapping the call in try/catch to see if there is an underlying error - there is definitely an exception at the call to thing:new_with(), but no further information is available.

The stacktrace reports:

{thing,new,[["name","value"]]}
{home_controller,create,1}
{home_controller,handle_request,3}
{beepbeep,process_request,4}
{test_web,loop,1}
{mochiweb_http,headers,4}
{proc_lib,init_p_do_apply,3}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那片花海 2024-08-06 08:37:59

使用模式匹配来断言事情在调用 thing:new/1 之前正常工作:

ok = erlydb:start(mysql,Database),
ok = erlydb:code_gen(["thing.erl"],mysql), 

您仅包含堆栈跟踪,同时查看异常消息。 我怀疑错误是您收到“undef”异常。 但检查一下是否确实如此。 堆栈跟踪中的第一行表明以 ["name", "value"] 作为参数调用 thing:new/1 时出现问题。

有点奇怪的是,您显示的 handle_request 的一个子句没有按照堆栈跟踪中的 {home_controller,create,1} 调用 home_controller:create/1 。 handle_request/2 函数中的其他子句是什么样的?

Use pattern matching to assert that things work up to the call to thing:new/1:

ok = erlydb:start(mysql,Database),
ok = erlydb:code_gen(["thing.erl"],mysql), 

You include only the stack trace, look at the exception message as well. I suspect that the error is that you get an 'undef' exception. But check that it is so. The first line in the stack trace indicates that it is a problem with calling thing:new/1 with ["name", "value"] as argument.

It is slightly odd that you show one clause of handle_request that is not calling home_controller:create/1 as per {home_controller,create,1} in the stack-trace. What do the other clauses in your handle_request/2 function look like?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文