Skip to content

Commit 2f5d24a

Browse files
authored
FlxSave: Replace FlxSaveStatus.ERROR with SAVE_ERROR (#3294)
* replace `FlxSaveStatus.ERROR` with SAVE_ERROR * update changelog * add link * Add deprecated ERROR back
1 parent 27a756b commit 2f5d24a

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
6.0.0 (TBD)
22

3-
#### Removals
3+
#### Removals and Breaking Changes
44
We removed many features and utilities that were previously deprecated
55
- `flixel.util.FlxPath`: New package, `flixel.path.FlxPath`
66
- `FlxSwipe::angle`: Use `FlxSwipe.degrees`, instead
@@ -25,6 +25,9 @@ We removed many features and utilities that were previously deprecated
2525
- `FlxAssets.FlxAngelCodeSource`: Use `FlxAssets.FlxAngelCodeAsset`, instead
2626
- `FlxAssets.FlxTexturePackerSource`: Use `FlxTexturePackerJsonAsset`, instead
2727
- `FlxUnicodeUtil`: Use `UnicodeString`, instead
28+
- `FlxState::switchTo`: Use `startOutro`, instead ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733))
29+
- `FlxCamera.defaultCameras`: Use `FlxG.cameras.setDefaultDrawTarget`, instead
30+
- `FlxSave`: Deprecate and remove all uses of `FlxSaveStatus.ERROR` for `FlxSaveStatus.SAVE_ERROR` ([#3294](https://github.com/HaxeFlixel/flixel/pull/3294))
2831

2932
#### Changes and improvements:
3033
- `FlxSpritegroup`: Setting `origin` now causes members to pivot around the same point ([#2981](https://github.com/HaxeFlixel/flixel/pull/2981))

flixel/util/FlxSave.hx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package flixel.util;
22

33
import flixel.util.FlxDestroyUtil.IFlxDestroyable;
44
import haxe.Exception;
5-
import openfl.errors.Error;
65
import openfl.net.SharedObject;
76
import openfl.net.SharedObjectFlushStatus;
87

@@ -211,7 +210,7 @@ class FlxSave implements IFlxDestroyable
211210
return false;
212211
}
213212
}
214-
catch (e:Error)
213+
catch (e)
215214
{
216215
FlxG.log.error('Error:${e.message} name:"$name", path:"$path".');
217216
destroy();
@@ -308,14 +307,14 @@ class FlxSave implements IFlxDestroyable
308307

309308
try
310309
{
311-
var result = _sharedObject.flush(minFileSize);
310+
final result = _sharedObject.flush(minFileSize);
312311

313312
if (result != FLUSHED)
314-
status = ERROR("FlxSave is requesting extra storage space.");
313+
status = SAVE_ERROR(STORAGE);
315314
}
316-
catch (e:Error)
315+
catch (e)
317316
{
318-
status = ERROR("There was an problem flushing the save data.");
317+
status = SAVE_ERROR(ENCODING(e));
319318
}
320319

321320
checkStatus();
@@ -353,8 +352,10 @@ class FlxSave implements IFlxDestroyable
353352
return true;
354353
case EMPTY:
355354
FlxG.log.warn("You must call save.bind() before you can read or write data.");
356-
case ERROR(msg):
357-
FlxG.log.error(msg);
355+
case SAVE_ERROR(STORAGE):
356+
FlxG.log.error("FlxSave is requesting extra storage space");
357+
case SAVE_ERROR(ENCODING(e)):
358+
FlxG.log.error('There was an problem encoding the save data: ${e.message}');
358359
case LOAD_ERROR(IO(e)):
359360
FlxG.log.error('IO ERROR: ${e.message}');
360361
case LOAD_ERROR(INVALID_NAME(name, reason)):
@@ -741,6 +742,15 @@ enum LoadFailureType
741742
PARSING(rawData:String, exception:Exception);
742743
}
743744

745+
enum SaveFailureType
746+
{
747+
/** FlxSave is requesting extra storage space **/
748+
STORAGE;
749+
750+
/** There was an problem encoding the save data */
751+
ENCODING(e:Exception);
752+
}
753+
744754
enum FlxSaveStatus
745755
{
746756
/**
@@ -754,12 +764,16 @@ enum FlxSaveStatus
754764
BOUND(name:String, ?path:String);
755765

756766
/**
757-
* There was an issue during `flush`
767+
* There was an issue during `flush`. Previously known as `ERROR(msg:String)`
758768
*/
759-
ERROR(msg:String);
769+
SAVE_ERROR(type:SaveFailureType);
760770

761771
/**
762772
* There was an issue while loading
763773
*/
764774
LOAD_ERROR(type:LoadFailureType);
775+
776+
@:noCompletion
777+
@:deprecated("FlxSaveStatus.ERROR is never used, it has been replaced by SAVE_ERROR")
778+
ERROR(msg:String);
765779
}

0 commit comments

Comments
 (0)