Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Easter Egg?

in Questions Posts: 815

Since when was error(string) a thing? It was always ‘assert(boolean, string)! Did ‘error() came with craft?

Comments

  • dave1707dave1707 Mod
    Posts: 7,605

    @TokOut I see error all the way back to version 1.5, so it’s nothing new. What it’s used for I don’t know because I didn’t find anything in the reference.

  • Posts: 815

    @dave1707 as I told above it’s basically error(txt) instead of assert(false, txt)

  • dave1707dave1707 Mod
    Posts: 7,605

    @TokOut assert and error are both in the current code. Do you have an example of how you’re using error instead of assert.

  • edited October 2017 Posts: 815
    function setup()
        error("Test")
    end
    
    --[[
    Main:3: Test
    stack traceback:
        [C]: in function 'error'
        Main:3: in function 'setup'
    
    EXPECTED:
    Main:3: attempt to call a nil value (global 'error')
    stack traceback:
        Main:3: in function 'setup'
    ]]
    

    So it’s the same as assert.

Sign In or Register to comment.