SaveText with fail-safe?

BlitzMax Forums/BlitzMax Beginners Area/SaveText with fail-safe?

Hi!

How can I add a fail-safe to this funtion so that it doesn't crash on errors (File couldn't be written e.g.)?

Thanks Grisu

try/catch?

If I use Savetext on a dir + filename that doesn't exist it simply crashes. The function itself doesn't return true of false like other file commands. So I can't catch an error that way.

So I can't catch an error that way.

Yes you can.
Try
	SaveText( "haha", "c:\..")
Catch e:Object
	Print "oops"
EndTry


Oops :) Didn't know of this command.

It catches the first error, but it crashes as soon as you do the same mistake again?

For i:int=0 To 10
Try
	SaveText( "haha", "c:\...")
Catch e:Object
	Print "oops"
EndTry
Next 


BLR needs to add some error catching to Savetext() ( and maybe Loadtext()?), to make them report some errors like other functions do.

I've reported a similar problem in the past: http://blitzmax.com/Community/posts.php?topic=68176#761629

It catches the first error, but it crashes as soon as you do the same mistake again?

This is a bit weird, it behaves like you would expect in Debug mode with all different types of exceptions.
But in Release mode, it only allows ONE null pointer exception, all the others work as expected.

Might be a bug??