Possible to get Error Type?

Hey Developers,

Basically I want to know if it is in any way possible to get the error type in a pcall.

My code:

local succ, err = pcall(function()

if succ then
	print('[I want this to be the error type]: '..err)

I’m not quite sure what you mean by error type, could you explain?

Perhaps if the error was like ‘Object Doesn’t Exist’ or something like ‘Blah is a nil value’ [I want this to be the error type]: would change to a custom string

I can’t really think of using anything other than string.find on the error and setting it up so that if a certain word is in the error it prints your custom error, but I don’t get why you want to do this. It’s inefficient and you can’t handle every scenario to exist. What’s wrong with just printing the error?

1 Like

I’m going to print something like “[Missing Object]: Hello is not a valid member of Workspace” etc, and thanks for the info! :slight_smile: