Author Topic: Return codes (ERRORLEVEL) doesn't seem to work  (Read 1242 times)

Steveatoni

  • Guest
Return codes (ERRORLEVEL) doesn't seem to work
« on: January 23, 2018, 05:56:07 PM »
Long break from modding, but just started back up and had to tweak a few of my old batch files to get going again. But the errorlevels as documented in 13.2 don't seem to work the same anymore. An snippet from a batch file that used to work:

Code: [Select]
if "%1"=="" goto helper
if "%2"=="" goto simple
Echo ====== Extracting Dialog =======
weidu %1.dlg --out w --text --transitive --full-from > nul
if errorlevel 1 goto oops
Echo ========= Complete =============

It used to go to label oops if I typed in something invalid (in this case, something like "joiaa" instead of "joia" in BG1) but it looks to me as if WeiDU is no longer returning codes? It's just continuing on as if all was well.

I removed the redirection into nul as a workaround, so I can Ctrl-Break rather than use the error handling code I sent it to that could recover from most of my typos.

BTW, when I say "used to", I'm mean 2010...

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #1 on: January 24, 2018, 12:38:02 PM »
As far as I can tell, WeiDU has never had a non-zero return value for a failure to decompile a DLG on the command line. Before v241, the return values were
Code: [Select]
0 Success
1 Failure to install TP2 component
2 Something about autoupdate
3 Something else about autoupdate
4 Invalid command-line arguments
Edit: also detailed in ye olde rædan-me from Weimer's days.

In v241 and later, the return values are listed here. Source control goes back to Jan 26 2009, beyond that I don't know what changes were made (edit: aside from the fact they have probably been constant since v185, at least).
« Last Edit: January 24, 2018, 01:09:55 PM by Wisp »

Steveatoni

  • Guest
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #2 on: January 24, 2018, 01:26:03 PM »
It's possible I never made a typo when calling that particular .bat file (which is usually called  by other .bat files, not invoked manually). Or if I did, I never noticed that I didn't get the file I thought I decompiled. Maybe that happens to be one of those actions which do not set exit codes. Looks like BCS is another one.

I'll soon have a little better idea when I get the rest of the .bat files updated for EE and all the rest of the installs. I used to use the exit codes to generate an error log that I kept open on a second monitor so I didn't have to try to remember everything that errored out. Weidu had to have generated exit codes for some of those actions, mostly finding and extracting resources and strings, or I would never have had an error log to have open.

Steveatoni

  • Guest
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #3 on: January 24, 2018, 01:54:30 PM »
It's not really that big of a deal. Rather than redirect to nul, I can redirect to a file and search it for the words "FATAL ERROR" that Weidu prints to console. Pretty much what I do searching override files with DOS anyway. At least then I'm doing all the error processing consistently.

Evidently, I'm the only one who's used exit codes to do modding, so certainly not worth a feature request.

Just seems odd that anything worth calling a fatal error wouldn't return an error code.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #4 on: January 27, 2018, 03:02:46 AM »
Just seems odd that anything worth calling a fatal error wouldn't return an error code.
I agree, but that's where we are today.

Steveatoni

  • Guest
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #5 on: January 27, 2018, 03:46:40 PM »
I found my issue. These particular batch files were only called if one of the overrides (I kept parallel structures of chitin, dialog and override for each mod I wanted to test for compatibility) contained a modified dialog or script. So apart from maybe a copy fail,  or maybe a corrupted compile someone else's mod didn't catch, there should have been no errors generated. So if I was tweaking Mazzy, it would only extract from mods which had also tweaked Mazzy, because those were the only ones I'd have to know what was changed.

Sorry to have put you to the trouble, but I sure appreciate that you looked into it.

Steveatoni

  • Guest
Re: Return codes (ERRORLEVEL) doesn't seem to work
« Reply #6 on: January 27, 2018, 03:53:02 PM »
In case it wasn't clear, FILE NOT FOUND could not happen, as the conditional to get there was FILE EXISTS. If the file did not exist, it wouldn't have been called, and no error thrown.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: