Using pcall and running a function contained within a module still produces an error in output

If you use pcall and call a function within a module it will still be shown in the output window. This is causing me issues since I am trying to set up custom error handling for ‘plugins’ that players can add to a utility script I am working on.

Script: module = require(ModuleScript) local _, error = pcall(function () module.Test() end) print(error)

Module Script:[code]
module = {}

module.Test = function ()
error(“This is an error.”, 0)
end

return module
[/code]

Output:
[size=2]19:49:05.399 - This is an error.[/size]
[size=2]This is an error.[/size]

2 Likes

I’ve noticed this behavior with my modules as well. Would love for it to be fix

This also happens with bindable functions

I’ve copy/pasted your scripts into this test place but I’m not seeing the red error text when I do play solo. Is it possible that the error is lingering in the output window from a run before you added the pcall?

I am not seeing any errors either now. Could this have been patched since the original post? I will check another bit of code that utilizes this when I get the opportunity later today.

Nope - 4 and a half years later I still get the error “Module code did not return exactly one value” even when the (empty) module is required from inside of a pcall.

This sounds like an unrelated issue. You should create a new post for it if so.