Get only error information and not full instance name

Is there any ways to make xpcall only return the actual error and not the script full instance name?

xpcall(function()
  RealTable[fakevalue](nil)
end,function(a0)
  print(a0) -- would print script:GetFullName() along with error itself, which I only want the error.
end)

I can’t seem to find any way to do it without the instance name, however you can manipulate the string to get everything after the instance name:

local RealTable = {}
xpcall(function()
	RealTable[" "](nil)
end,function(a0)
	local a1 = table.concat(string.split(a0, ":"), "", 3)
	print(a1)
end)

This seems to result in there being an addition " " at the start of the string, so you may also wish to remove that:

local RealTable = {}
xpcall(function()
	RealTable[" "](nil)
end,function(a0)
	local a1 = string.sub(table.concat(string.split(a0, ":"), "", 3), 2)
	print(a1)
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.