-- Define a function that may produce an error
function divide(a, b)
if b == 0 then
error("Division by zero")
end
return a / b
end
-- Call the function with pcall
local success, result = pcall(divide, 10, 0)
-- Check if the call was successful
if success then
print("Result:", result)
else
print("Error:", result)
end