1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-25 06:33:23 +00:00

Merge pull request #390 from Wilma456/ComputerCraft-1/errormsg

Show fs error in paint and edit
This commit is contained in:
SquidDev 2017-11-15 16:39:37 +00:00
commit 6691ec8e3a
2 changed files with 18 additions and 8 deletions

View File

@ -93,7 +93,7 @@ local function save( _sPath )
-- Save
local file = nil
local function innerSave()
file = fs.open( _sPath, "w" )
file, fileerr = fs.open( _sPath, "w" )
if file then
for n, sLine in ipairs( tLines ) do
file.write( sLine .. "\n" )
@ -107,7 +107,7 @@ local function save( _sPath )
if file then
file.close()
end
return ok, err
return ok, err, fileerr
end
local tKeywords = {
@ -287,11 +287,15 @@ local tMenuFuncs = {
if bReadOnly then
sStatus = "Access denied"
else
local ok, err = save( sPath )
local ok, err, fileerr = save( sPath )
if ok then
sStatus="Saved to "..sPath
else
sStatus="Error saving to "..sPath
if fileerr then
sStatus="Error saving to "..fileerr
else
sStatus="Error saving to "..sPath
end
end
end
redrawMenu()
@ -770,3 +774,4 @@ end
term.clear()
term.setCursorBlink( false )
term.setCursorPos( 1, 1 )

View File

@ -128,9 +128,9 @@ local function save(path)
fs.makeDir(sDir)
end
local file = fs.open( path, "w" )
local file, err = fs.open( path, "w" )
if not file then
return false
return false, err
end
-- Encode (and trim)
@ -313,11 +313,15 @@ local function accessMenu()
fMessage = "Access denied"
return false
end
local success = save(sPath)
local success, err = save(sPath)
if success then
fMessage = "Saved to "..sPath
else
fMessage = "Error saving to "..sPath
if err then
fMessage = "Error saving to "..err
else
fMessage = "Error saving to "..sPath
end
end
return false
elseif mChoices[selection]=="Exit" then
@ -401,3 +405,4 @@ term.setBackgroundColour(colours.black)
term.setTextColour(colours.white)
term.clear()
term.setCursorPos(1,1)