Added using exception handling to check the triangle