Difference between revisions of "love.threaderror"

(Created page)
 
(Add comment about default behaviour if not overwritten.)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{newin|[[0.9.0]]|090|type=callback}}
 
{{newin|[[0.9.0]]|090|type=callback}}
Callback function triggered when a [[Thread]] encounters an error.
+
Callback function triggered when a [[Thread]] encounters an error. If not overwritten this callback will raise an error containing the error message of the threaderror.
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 13: Line 13:
 
== Example ==
 
== Example ==
 
<source lang="lua">
 
<source lang="lua">
 +
function love.load()
 +
  mythread = love.thread.newThread("thread.lua")
 +
  mythread:start()
 +
end
 +
 
function love.threaderror(thread, errorstr)
 
function love.threaderror(thread, errorstr)
 
   print("Thread error!\n"..errorstr)
 
   print("Thread error!\n"..errorstr)
 +
  -- thread:getError() will return the same error string now.
 
end
 
end
 
</source>
 
</source>
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::love]]
 
* [[parent::love]]
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]
 
{{#set:Description=Callback function triggered when a [[Thread]] encounters an error.}}
 
{{#set:Description=Callback function triggered when a [[Thread]] encounters an error.}}
 +
{{#set:Subcategory=General}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.threaderror}}
 
{{i18n|love.threaderror}}

Latest revision as of 19:04, 26 May 2024

Available since LÖVE 0.9.0
This callback is not supported in earlier versions.

Callback function triggered when a Thread encounters an error. If not overwritten this callback will raise an error containing the error message of the threaderror.

Function

Synopsis

love.threaderror( thread, errorstr )

Arguments

Thread thread
The thread which produced the error.
string errorstr
The error message.

Returns

Nothing.

Example

function love.load()
  mythread = love.thread.newThread("thread.lua")
  mythread:start()
end

function love.threaderror(thread, errorstr)
  print("Thread error!\n"..errorstr)
  -- thread:getError() will return the same error string now.
end

See Also


Other Languages