Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor GT-ERR-01 #2045

Merged

Conversation

have-fun-was-taken
Copy link
Contributor

It felt like a waste to have a screen's worth of space filled by the print of this error, so I rephrased it and refactored it to the bottom of the file.

I also flipped the if that contained the check in order to follow the principle of checking for the desired outcome first.

The change has been tested by forcing the error branch of if being looped once instead of the usual one. The results are as follows.
Before the change:

[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: GT-ERR-01: @ ic2.itemTinCanFilled   (Filled) Tin Can
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: A Recipe used an OreDict Item as Output directly, without copying it before!!! This is a typical CallByReference/CallByValue Error
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Said Item will be renamed to make the invalid Recipe visible, so that you can report it properly.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Please check all Recipes outputting this Item, and report the Recipes to their Owner.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: The Owner of the ==>RECIPE<==, NOT the Owner of the Item, which has been mentioned above!!!
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: And ONLY Recipes which are ==>OUTPUTTING<== the Item, sorry but I don't want failed Bug Reports.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: GregTech just reports this Error to you, so you can report it to the Mod causing the Problem.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Even though I make that Bug visible, I can not and will not fix that for you, that's for the causing Mod to fix.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: And speaking of failed Reports:
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Both IC2 and GregTech CANNOT be the CAUSE of this Problem, so don't report it to either of them.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: I REPEAT, BOTH, IC2 and GregTech CANNOT be the source of THIS BUG. NO MATTER WHAT.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Asking in the IC2 Forums, which Mod is causing that, won't help anyone, since it is not possible to determine, which Mod it is.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: If it would be possible, then I would have had added the Mod which is causing it to the Message already. But it is not possible.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Sorry, but this Error is serious enough to justify this Wall-O-Text and the partially allcapsed Language.
[22:12:47] [Server thread/ERROR] [GregTech GTNH/gregtech]: Also it is a Ban Reason on the IC2-Forums to post this seriously.

After the change:

[22:23:02] [Server thread/ERROR] [GregTech GTNH/gregtech]: GT-ERR-01 at ic2.itemTinCanFilled   (Filled) Tin Can
[22:23:02] [Server thread/ERROR] [GregTech GTNH/gregtech]: A recipe used an OreDict item as output directly, without copying the item before that. This is a typical CallByReference/CallByValue error.
[22:23:02] [Server thread/ERROR] [GregTech GTNH/gregtech]: The said item will be renamed to make the invalid recipe visible.
[22:23:02] [Server thread/ERROR] [GregTech GTNH/gregtech]: Please check all recipes that output this item, and report them to the mod that introduced the recipes.

Add two functions at the bottom:
one contains the error message, the other one prints it.

This refactor puts the error at the end of the file, so you don't have to
scroll through a screen's worth of space when debugging this file.
It is questionable to put the case that is considered "wrong" as the first one,
and do the most common result as "else".

The flipped "if" essentially says
"if condition then do the usual, otherwise handle the error."
@have-fun-was-taken have-fun-was-taken marked this pull request as ready for review June 2, 2023 21:13
@Dream-Master Dream-Master requested review from a team June 2, 2023 21:22
@Dream-Master Dream-Master merged commit ae5b5f3 into GTNewHorizons:master Jun 2, 2023
2 checks passed
@have-fun-was-taken have-fun-was-taken deleted the refactor/gt-err-01 branch June 3, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants