Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Lua Quick Start Guide

You're reading from  Lua Quick Start Guide

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789343229
Pages 202 pages
Edition 1st Edition
Languages
Author (1):
Gabor Szauer Gabor Szauer
Profile icon Gabor Szauer

Error-handling in Lua

Lua does not officially support exceptions. But, a similar mechanism can be built with pcalls, or protected calls. An exception halts the flow of code in case of an error, and returns control to the caller right away. Furthermore, some kind of error code is likely provided to the caller. This method of raising errors immediately should, in theory, allow callers to handle unsafe code gracefully.

Much like debugger.lua, third-party Lua modules for profiling already exist. Unsurprisingly, one of the best modules for profiling is profile.lua. You can learn more about profile.lua and download it here: https://bitbucket.org/itraykov/profile.lua

pcall and error

Lua's most efficient way to handle errors...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}