mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-20 12:33:14 +00:00
Error elaborator (#891)
* elaborate error messages * removed accidental change for some reason godot changes main.tscn gets changed when i open it * Update Main.tscn removed accidental change part 2 * formatting * formatting * formatting * lint ignore
This commit is contained in:
parent
75c737f552
commit
eec986b466
5 changed files with 128 additions and 5 deletions
|
@ -357,6 +357,7 @@ Export="*res://src/Autoload/Export.gd"
|
|||
Palettes="*res://src/Autoload/Palettes.gd"
|
||||
Keychain="*res://addons/keychain/Keychain.gd"
|
||||
ExtensionsApi="*res://src/Autoload/ExtensionsAPI.gd"
|
||||
ErrorManager="*res://src/Autoload/ErrorManager.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
|
|
108
src/Autoload/ErrorManager.gd
Normal file
108
src/Autoload/ErrorManager.gd
Normal file
|
@ -0,0 +1,108 @@
|
|||
extends Node
|
||||
|
||||
|
||||
func parse(error: int, start := "", end := ""):
|
||||
var message: String
|
||||
match error:
|
||||
OK:
|
||||
message = "everything is fine"
|
||||
FAILED:
|
||||
message = "Generic error."
|
||||
ERR_UNAVAILABLE:
|
||||
message = "Unavailable error."
|
||||
ERR_UNCONFIGURED:
|
||||
message = "Unconfigured error."
|
||||
ERR_UNAUTHORIZED:
|
||||
message = "Unauthorized error."
|
||||
ERR_PARAMETER_RANGE_ERROR:
|
||||
message = "Parameter range error."
|
||||
ERR_OUT_OF_MEMORY:
|
||||
message = "Out of memory (OOM) error."
|
||||
ERR_FILE_NOT_FOUND:
|
||||
message = "File: Not found error."
|
||||
ERR_FILE_BAD_DRIVE:
|
||||
message = "File: Bad drive error."
|
||||
ERR_FILE_BAD_PATH:
|
||||
message = "File: Bad path error."
|
||||
ERR_FILE_NO_PERMISSION:
|
||||
message = "File: No permission error."
|
||||
ERR_FILE_ALREADY_IN_USE:
|
||||
message = "File: Already in use error."
|
||||
ERR_FILE_CANT_OPEN:
|
||||
message = "File: Can't open error."
|
||||
ERR_FILE_CANT_WRITE:
|
||||
message = "File: Can't write error."
|
||||
ERR_FILE_CANT_READ:
|
||||
message = "File: Can't read error."
|
||||
ERR_FILE_UNRECOGNIZED:
|
||||
message = "File: Unrecognized error."
|
||||
ERR_FILE_CORRUPT:
|
||||
message = "File: Corrupt error."
|
||||
ERR_FILE_MISSING_DEPENDENCIES:
|
||||
message = "File: Missing dependencies error."
|
||||
ERR_FILE_EOF:
|
||||
message = "File: End of file (EOF) error."
|
||||
ERR_CANT_OPEN:
|
||||
message = "Can't open error."
|
||||
ERR_CANT_CREATE:
|
||||
message = "Can't create error."
|
||||
ERR_QUERY_FAILED:
|
||||
message = "Query failed error."
|
||||
ERR_ALREADY_IN_USE:
|
||||
message = "Already in use error."
|
||||
ERR_LOCKED:
|
||||
message = "Locked error."
|
||||
ERR_TIMEOUT:
|
||||
message = "Timeout error."
|
||||
ERR_CANT_CONNECT:
|
||||
message = "Can't connect error."
|
||||
ERR_CANT_RESOLVE:
|
||||
message = "Can't resolve error."
|
||||
ERR_CONNECTION_ERROR:
|
||||
message = "Connection error."
|
||||
ERR_CANT_ACQUIRE_RESOURCE:
|
||||
message = "Can't acquire resource error."
|
||||
ERR_CANT_FORK:
|
||||
message = "Can't fork process error."
|
||||
ERR_INVALID_DATA:
|
||||
message = "Invalid data error."
|
||||
ERR_INVALID_PARAMETER:
|
||||
message = "Invalid parameter error."
|
||||
ERR_ALREADY_EXISTS:
|
||||
message = "Already exists error."
|
||||
ERR_DOES_NOT_EXIST:
|
||||
message = "Does not exist error."
|
||||
ERR_DATABASE_CANT_READ:
|
||||
message = "Database: Read error."
|
||||
ERR_DATABASE_CANT_WRITE:
|
||||
message = "Database: Write error."
|
||||
ERR_COMPILATION_FAILED:
|
||||
message = "Compilation failed error."
|
||||
ERR_METHOD_NOT_FOUND:
|
||||
message = "Method not found error."
|
||||
ERR_LINK_FAILED:
|
||||
message = "Linking failed error."
|
||||
ERR_SCRIPT_FAILED:
|
||||
message = "Script failed error."
|
||||
ERR_CYCLIC_LINK:
|
||||
message = "Cycling link (import cycle) error."
|
||||
ERR_INVALID_DECLARATION:
|
||||
message = "Invalid declaration error."
|
||||
ERR_DUPLICATE_SYMBOL:
|
||||
message = "Duplicate symbol error."
|
||||
ERR_PARSE_ERROR:
|
||||
message = "Parse error."
|
||||
ERR_BUSY:
|
||||
message = "Busy error."
|
||||
ERR_SKIP:
|
||||
message = "Skip error."
|
||||
ERR_HELP:
|
||||
message = "Help error."
|
||||
ERR_BUG:
|
||||
message = "Bug error."
|
||||
ERR_PRINTER_ON_FIRE:
|
||||
# gdlint: ignore=max-line-length
|
||||
message = "Printer on fire error. (This is an easter egg, no engine methods return this error code.)"
|
||||
_:
|
||||
message = "Unknown error"
|
||||
return str(start, message, end)
|
|
@ -266,7 +266,12 @@ func export_processed_images(
|
|||
else:
|
||||
var err: int = processed_images[i].save_png(export_paths[i])
|
||||
if err != OK:
|
||||
Global.error_dialog.set_text(tr("File failed to save. Error code %s") % err)
|
||||
Global.error_dialog.set_text(
|
||||
(
|
||||
tr("File failed to save. Error code %s")
|
||||
% str(err, ErrorManager.parse(err, " (", ")"))
|
||||
)
|
||||
)
|
||||
Global.error_dialog.popup_centered()
|
||||
Global.dialog_open(true)
|
||||
succeeded = false
|
||||
|
|
|
@ -64,7 +64,10 @@ func handle_loading_file(file: String) -> void:
|
|||
if err != OK: # An error occurred
|
||||
var file_name: String = file.get_file()
|
||||
Global.error_dialog.set_text(
|
||||
tr("Can't load file '%s'.\nError code: %s") % [file_name, str(err)]
|
||||
(
|
||||
tr("Can't load file '%s'.\nError code: %s")
|
||||
% [file_name, str(err, ErrorManager.parse(err, " (", ")"))]
|
||||
)
|
||||
)
|
||||
Global.error_dialog.popup_centered()
|
||||
Global.dialog_open(true)
|
||||
|
@ -120,7 +123,9 @@ func open_pxo_file(path: String, untitled_backup: bool = false, replace_empty: b
|
|||
err = file.open(path, File.READ) # If the file is not compressed open it raw (pre-v0.7)
|
||||
|
||||
if err != OK:
|
||||
Global.error_dialog.set_text(tr("File failed to open. Error code %s") % err)
|
||||
Global.error_dialog.set_text(
|
||||
tr("File failed to open. Error code %s") % str(err, ErrorManager.parse(err, " (", ")"))
|
||||
)
|
||||
Global.error_dialog.popup_centered()
|
||||
Global.dialog_open(true)
|
||||
file.close()
|
||||
|
@ -391,7 +396,11 @@ func save_pxo_file(
|
|||
err = file.open(temp_path, File.WRITE)
|
||||
|
||||
if err != OK:
|
||||
Global.error_dialog.set_text(tr("File failed to save. Error code %s") % err)
|
||||
if temp_path.is_valid_filename():
|
||||
return true
|
||||
Global.error_dialog.set_text(
|
||||
tr("File failed to save. Error code %s") % str(err, ErrorManager.parse(err, " (", ")"))
|
||||
)
|
||||
Global.error_dialog.popup_centered()
|
||||
Global.dialog_open(true)
|
||||
file.close()
|
||||
|
|
|
@ -141,7 +141,7 @@ func _add_extension(file_name: String) -> void:
|
|||
var extension_config_file := File.new()
|
||||
var err := extension_config_file.open(extension_config_file_path, File.READ)
|
||||
if err != OK:
|
||||
print("Error loading config file: ", err)
|
||||
print("Error loading config file: ", err, ErrorManager.parse(err, " (", ")"))
|
||||
extension_config_file.close()
|
||||
return
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue