Thread Tools Display Modes
11-12-17, 08:03 PM   #1
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
Naive Question: assert() error message

This is my first foray into LUA and WoW Addon development. So apologies in advance for the naivity.

Note the call to assert() in the function below. While it terminates the program correctly, it doesn't print the error message to the chat frame.

This is so simple that I'm convinced I'm missing something. Does assert(), for example, use a different output that the chat frame?

Any help would be very much appreciated.

Code:
function debugPlay()

	assert( nil, "function terminated.")
	
	stackInfo = debugstack()
	print( stackInfo )
	

	-- 
	-- Get the line number from where the function was called
	--
	for number in string.gmatch(stackInfo, "%d+>")
		do
			print("Function definition at line ", string.match( number, "%d+"))
	        end
	
	
	-- 
	-- Get line number where function was called.
	--
	for number in string.gmatch(stackInfo, "%d+:")
		do
			print("Function called at line ", string.match( number, "%d+"))
	end

end
  Reply With Quote
11-12-17, 10:06 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
assert() does not print a chat message, it raises a Lua error. You won't see it if you have Lua errors disabled or whatever error catching addon you may be using is hiding it.
  Reply With Quote
11-12-17, 10:13 PM   #3
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,871
It prints to the error output.

If you have BugGrabber and BugSack intalled

Code:
/run local function debugPlay()
	assert( nil, "function terminated.")
end
 debugPlay()

BugSack will display:
1x [string "local function debugPlay() assert( nil, ..."]:1: function terminated.
Edit: Oops too late
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
11-13-17, 07:15 AM   #4
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
Kanegasi and Fizzlemizz - Thanks to you both. I thought it might be something like that.
  Reply With Quote
11-13-17, 01:47 PM   #5
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
Completely off-topic, but since you mentioned you're new at this, please have a look at how to scope your variables properly.
Generally speaking, global variables should only be used for things you want to access externally.
__________________
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Naive Question: assert() error message

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off