# Get the last error thrown by an attribute method

from maptek import vulcan

input_tri = "pit_solid.00t"  # triangulation to use

with vulcan.tri_attributes(input_tri) as tri:  # open triangulation in read mode
    tri.is_ok()  # Check triangulation is open and ready to add attributes

    # Add attribute
    tri.put('flagged', '2', 'Boolean')

    # get last error, blank if no error. In this case, the second argument passed
    # to the method above is invalid. Boolean operations only accept 0 or 1, not a 2.
    last_error = tri.get_last_error()
    print(f"Error: {last_error}")

    tri.save()  # save the attribute data