[Close please]anyone know where to redefine "rescue"[Answer:Can't be done]

● ARCHIVED · READ-ONLY
Started by estriole 5 posts View original ↗
  1. example we can do:

    begin whatever coderescue  whatever elseend
    Code:
     whatever rescue whatever else
    can we add something to the 'rescue' (method??) without touching that line (so it affect all rescue).

    (like redefine rescue)

    i try:

    module Kernelalias est_rescue rescueendbut no method error... where should i alias rescue to modify it's behavior

    i also list all Kernel methods, protected_methods ,private_methods,singleton_methods

    but cannot found rescue... where's the rescue placed anyway???

    i want to do something if there's error happening (NameError, etc). i want it to delete file i generate at the start of the script...(i have the code for deletion part).
  2. Can't you just do that in your rescue?
  3. You can't redefine rescue this way as it's not a method but a reserved word for ruby, and redefining a reserved word needs to change the related parts of the ruby programming language itself.

    If I were you, I'd rather make something like this:

    begin $rescue_code = whatever_rescue_code if whatever whatever_coderescue $rescue_code ? Global_Rescue.global_rescue($rescue_code) : whatever_rescueendor this:

    def whatever_method(whatever_passed, rescue_code = nil) begin method_code rescue rescue_code ? Global_Rescue.global_rescue(rescue_code) : method_rescue endendOr if you're really, really proficient enough, you can change those related parts of the ruby programming language itself then patch and publish your changes as it's an open source language. But then you'd also change everything else in RGSS3 using rescue, probably causing lots of potential compatibility issues and possibly some other nasty troubles.
  4. That's not a method, it's a Ruby keyword. Besides that, you're not using a number of the features of rescue that you could... for instance, rescue can do certain things only when certain exceptions are encountered, and it can be paired with both ensure and else.

    def example(file)  file_handle = File.open(file, 'r')  dangerous_method(file_handle)rescue Errno::ENOENT  # Handle the exception raised if the given file does not exist.rescue ArgumentError # Could be raised by `dangerous_method`, who knows? Handle it.else # No exceptions raised, so let's continue on.  # Insert code here.ensure # Make sure the file handle is closed no matter what.  file_handle.close if file_handleendIn short, it's really quite powerful, and I really don't see why you would need to overwrite it.
  5. yeah... i also figured that out... rescue is not a method...(@ stack overflow)

    originally i want to make my EST_CS2 - SCRIPT CONTROL to be more secure...

    i manage to make people not easily alter the scripts... but with some extra effor... it can stil be stolen and written to a file... (me and caitsith2 try to break the security ourself). so i added extra layer of security by deleting any written file that generated AFTER script control and BEFORE cypher_key(second hidden encryption). the code is placed inside the second hidden script.

    but there's still a way to bypass it by intentionally exit after finish writting the file.... so the second hidden script never executed...

    i manage to prevent some of it by aliasing exit and exit! command... but no way to prevent if they exploit Exception error like NameError, etc...

    IF the rescue can be aliased and then redefined... i plan on checking what parameter that the rescue received.

    if it's any Exception error... do some failsafe prevention for people that stealing the scripts.

    but then i realize... even if i put that code. people can easily alter the code... (must be careful though to avoid sc check)...

    so i decide using dll instead... thanks on Tsukihime tutorial... i manage to use dll (still basic method though). so the script a little bit harder to crack now. so i guess this can be closed.

    Thank you for all your assistance. :D .