2012-07-26 8 views
0

나는 파일에서 읽은 문자열에 String.contains 방법을 사용하면 내 오파 응용 프로그램이 실패OPA : binary_to_string/String.contains 오류

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) 
: 나는 다음과 같은 오류가있어

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"}, 
    ] 
) 

rabbit 

내 코드에 어떤 문제가 있습니까 :

데이터 파일은 하나 개의 라인을 포함?

감사합니다.

답변

1

실제로 File.content에는 버그가 있으며, 다음 릴리스에서 수정 될 예정입니다. Btw은

function start() { 
     match(File.content_opt("data.txt")){ 
     case {none} :<>No file</> 
     case {some:content} : 
      txt = string_of_binary(content) 
      jlog(txt) 
      b = String.contains(txt, "Rabbit") 
      <>Hello Bug</> 
     } 
} 
+0

: 당신은 바람직 (및 작업) 안전 File.content_opt 기능을 사용할 수 있습니다 오파의 마지막 버전은 위의 버그가 수정되었습니다. –