mirror of
https://github.com/love2d/love.git
synced 2026-08-18 03:34:23 +02:00
Improved the error messages caused when invalid or missing arguments are given to ImageData and SoundData methods.
This commit is contained in:
@@ -75,6 +75,8 @@ local objectcache = setmetatable({}, {
|
||||
-- Overwrite existing functions with new FFI versions.
|
||||
|
||||
function SoundData:getSample(i)
|
||||
if type(i) ~= "number" then error("bad argument #1 to SoundData:getSample (expected number)", 2) end
|
||||
|
||||
local p = objectcache[self]
|
||||
|
||||
if not (i >= 0 and i < p.size/p.bytedepth) then
|
||||
@@ -91,6 +93,9 @@ function SoundData:getSample(i)
|
||||
end
|
||||
|
||||
function SoundData:setSample(i, sample)
|
||||
if type(i) ~= "number" then error("bad argument #1 to SoundData:setSample (expected number)", 2) end
|
||||
if type(sample) ~= "number" then error("bad argument #2 to SoundData:setSample (expected number)", 2) end
|
||||
|
||||
local p = objectcache[self]
|
||||
|
||||
if not (i >= 0 and i < p.size/p.bytedepth) then
|
||||
|
||||
Reference in New Issue
Block a user