comparison src/luan/modules/http/tools/Run.luan @ 1692:d6ec67fa4a61

tools for config files
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 14 Jun 2022 21:59:39 -0600
parents fa066aaa068c
children b82767112d8e
comparison
equal deleted inserted replaced
1691:8d4152398825 1692:d6ec67fa4a61
66 </body> 66 </body>
67 </html> 67 </html>
68 <% 68 <%
69 end 69 end
70 70
71 function Run.print_error(e,code)
72 Http.response.reset()
73 Http.response.headers["Content-Type"] = "text/plain; charset=utf-8"
74 Io.stdout = Http.response.text_writer()
75 print(e)
76 print()
77 print()
78 print_with_line_numbers(code)
79 end
80
71 function Run.run(code,source_name) 81 function Run.run(code,source_name)
72 try 82 try
73 Http.response.headers["Content-Type"] = "text/plain; charset=utf-8" 83 Http.response.headers["Content-Type"] = "text/plain; charset=utf-8"
74 local run = load(code,source_name) 84 local run = load(code,source_name)
75 run() 85 run()
76 return true 86 return true
77 catch e 87 catch e
78 Http.response.reset() 88 Run.print_error(e,code)
79 Http.response.headers["Content-Type"] = "text/plain; charset=utf-8"
80 Io.stdout = Http.response.text_writer()
81 print(e)
82 print()
83 print()
84 print_with_line_numbers(code)
85 return false 89 return false
86 end 90 end
87 end 91 end
88 92
89 function Run.respond() 93 function Run.respond()