Author Topic: TRY and FAIL  (Read 1302 times)

-Turambar90-

  • Guest
TRY and FAIL
« on: January 30, 2011, 08:49:51 AM »
I was testing some new code for my mod, which was using an ACTION_TRY:
Code: [Select]
VERSION ~beta 0010~

BEGIN ~prova~
SILENT
ACTION_TRY
 COPY - ~setup-prova.tp2~ ~trash.bin~
  REPLACE_EVALUATE "VERSION\( *\)~\( *\)\(b?e?t?a?\)\( *[a-z]* *\)\([0-9]+\)"
  BEGIN
    PATCH_IF (~%MATCH3%~ STRING_EQUAL_CASE ~beta~) AND (%MATCH5%<13) BEGIN
      PATCH_VERBOSE
      PATCH_FAIL ~old version~
    END
  END
  "VERSION%MATCH1%~%MATCH2%%MATCH3%%MATCH4%%MATCH5%"
 BUT_ONLY
WITH
~old version~
BEGIN
PRINT ~check~
ACTION_RERAISE
END
DEFAULT
 PRINT ~version not detected. Press any key to abort or c to continue~
 ACTION_READLN abort
 ACTION_IF ~%abort%~ STRING_MATCHES_REGEXP ~c.?~ BEGIN
  FAIL ~aborted~
 END
END
VERBOSE
I expected it to fail with error text "old version" (due to the ACTION_RERAISE), or at least to print "check". But neither of the two actions after WITH were performed, and the installation was successful.
It behaved, though, as expected (performing the DEFAULT actions, prompting and, if the input was not c, FAILing with message ~aborted~), when I copied a non existing file instead of setup-prova.tp2.
Is it the expected behaviour for a FAIL command in a TRY action?

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: TRY and FAIL
« Reply #1 on: January 30, 2011, 09:02:16 AM »
WITH checks against the exception string (which you can see by putting PRINT ~%ERROR_MESSAGE%~ in the DEFAULT section). In this case, ~%ERROR_MESSAGE%~ is ~Failure("old version")~; as such, you must use WITH ~Failure(\"old version\")~ rather than WITH ~old version~.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

-Turambar90-

  • Guest
Re: TRY and FAIL
« Reply #2 on: January 30, 2011, 09:13:25 AM »
The default section actions are not performed either.
DEFAULT
VERBOSE
PRINT ~%ERROR_MESSAGE%~
PRINT ~other string~
ACTION_READLN ...
END
did not result in any output, and the readln did not work either

Offline the bigg

  • The Avatar of Fighter / Thieves
  • Moderator
  • Planewalker
  • *****
  • Posts: 3804
  • Gender: Male
Re: TRY and FAIL
« Reply #3 on: January 30, 2011, 10:06:55 AM »
That's because PATCH_FAIL (or other errors) inside REPLACE_EVALUATE don't block the installation. Fixed.
Author or Co-Author: WeiDU (http://j.mp/bLtjOn) - Widescreen (http://j.mp/aKAiqG) - Generalized Biffing (http://j.mp/aVgw3U) - Refinements (http://j.mp/bLHoCc) - TB#Tweaks (http://j.mp/ba02Eg) - IWD2Tweaks (http://j.mp/98OFYY) - TB#Characters (http://j.mp/ak8J55) - Traify Tool (http://j.mp/g1Ry9A) - Some mods that I won't mention in public
Maintainer: Semi-Multi Clerics (http://j.mp/9UeIwB) - Nalia Mod (http://j.mp/dng9l0) - Nvidia Fix (http://j.mp/aRWjjg)
Code dumps: Detect custom secondary types (http://j.mp/hVzzXG) - Stutter Investigator (http://j.mp/gdtBn8)

If possible, send diffs, translations and other contributions using Git (http://j.mp/aBZFrq).

 

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)?: