mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-12-22 11:03:48 +01:00
add more error handling
This commit is contained in:
parent
0d955b48ea
commit
aec8343bc0
@ -218,20 +218,32 @@ function M.fetch_POST(request, response)
|
|||||||
|
|
||||||
local gcodeFiles = " "
|
local gcodeFiles = " "
|
||||||
local startCode = request:get("start_code")
|
local startCode = request:get("start_code")
|
||||||
if not startCode then
|
if startCode ~= nil then
|
||||||
gcodeFiles = gcodeFiles .. '/tmp/startcode '
|
gcodeFiles = gcodeFiles .. '/tmp/startcode '
|
||||||
io.open('/tmp/startcode', 'w+').write(startCode)
|
io.open('/tmp/startcode', 'w+').write(startCode)
|
||||||
end
|
end
|
||||||
|
|
||||||
local endCode = request:get("end_code")
|
local endCode = request:get("end_code")
|
||||||
if not endCode then
|
if endCode ~= nil then
|
||||||
gcodeFiles = gcodeFiles .. '/tmp/endcode '
|
gcodeFiles = gcodeFiles .. '/tmp/endcode '
|
||||||
io.open('/tmp/endcode', 'w+').write(endCode)
|
io.open('/tmp/endcode', 'w+').write(endCode)
|
||||||
end
|
end
|
||||||
|
|
||||||
local socket = printer:getId()
|
local socket = printer:getId()
|
||||||
|
if socket == nil then
|
||||||
|
response:setError("no socket found")
|
||||||
|
return
|
||||||
|
end
|
||||||
local remote = settings.get('gcode.server')
|
local remote = settings.get('gcode.server')
|
||||||
|
if remote == nil then
|
||||||
|
response:setError("no gcode server configured")
|
||||||
|
return
|
||||||
|
end
|
||||||
local id = request:get("id")
|
local id = request:get("id")
|
||||||
|
if id == nil then
|
||||||
|
response:setError("no id supplied")
|
||||||
|
return
|
||||||
|
end
|
||||||
io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles)
|
io.popen("print-fetch " .. socket .. " " .. remote .. " " .. id .. gcodeFiles)
|
||||||
response:setSuccess()
|
response:setSuccess()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user