当我对从文件读取的字符串使用 String.contains 方法时,我的 opa 应用程序失败:
import stdlib.io.file
import stdlib.core
function start()
{
txt = string_of_binary(File.content("data.txt"))
jlog(txt)
b = String.contains(txt, "Rabbit")
<>Hello Bug</>
}
Server.start(
{port:8092, netmask:0.0.0.0, encryption: {no_encryption}, name:"bug"},
[ {resources: @static_resource_directory("resources")},
{register: {css: []} },
{page: start, title: "bug"},
]
)
我有以下错误:
bug serving on http://ks3098156.kimsufi.com:8092
[Opa] Server dispatch Decoded URL to /
STDERR:rabbit
/home/kayhman/website/rstEditor/code/bug_depends/qmlCpsClientLib.js:26
_error = true;global.console.log("Uncaught exception : " + global.e.toString()
^
TypeError: Cannot call method 'toString' of undefined
at /home/kayhman/website/rstEditor/code/bug_depends/qmlCpsClientLib.js:26:222
at /home/kayhman/website/rstEditor/code/bug_depends/qmlCpsClientLib.js:27:78
at /home/kayhman/website/rstEditor/code/bug_depends/qmlCpsClientLib.js:22:128
at /home/kayhman/website/rstEditor/code/bug_depends/qmlCpsClientLib.js:28:263
at dispatcher_cps (/home/kayhman/website/rstEditor/code/bug_depends/bslNet.nodejs:60:165)
at Server.<anonymous> (/home/kayhman/website/rstEditor/code/bug_depends/bslNet.nodejs:59:437)
at Server.emit (events.js:70:17)
at HTTPParser.onIncoming (http.js:1514:12)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1410:22)
数据文件只包含一行:
rabbit
我的代码有什么问题?
谢谢