Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making the output print errors?

I have always wanted to know how to print out an error if something goes wrong and have it print exactly went wrong, I heard there is a way to use like an error service or something, I'm pretty much in the dust for all I know. Can anyone clarify?

I know how to print something in the output.

print('Hello')

But is it just simply doing that or is it something more advanced?

3 answers

✓ Accepted answer

For simple usage, you can just use the error function!

The error function on the Wiki

This, however, will stop any code that is not in a protected call so you usually shouldn't use it except to debug!

The TestService allows you to print Warnings (the Warn method) and errors (Error).

1 comment

0

Thanks! this is the exact function I was looking for, I couldn't recall it at first but I knew something existed like this. :)

You can use the TestService as a instance to print errors and warnings, just using the "error" function as BlueTaslem said! By the way, I want a faster and simpler method like java's try/catch one and converted to lua, like this:

// Java code
public void printHello() {
	try {
		System.out.println("Hello");
	} catch (Exception e) {
		System.err.println("The function cannot be called!");
		e.printStackTrace();
	}
}

-- Lua code
function printHello()
	try
		print("Hello");
	catch
		print("The function cannot be called!");
		error();
	end
end

Isn't it better?

This discussion is preserved as it was. New answers, comments, and votes are closed.