Error handling with pipmak.getimage/pipmak.newimage

View: New views
2 Messages — Rating Filter:   Alert me  

Error handling with pipmak.getimage/pipmak.newimage

by Andrea Viarengo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Chriss,

is there a reason why standard lua error handling functions doesn't work with
pipmak.getimage/pipmak.newimage?

I.e. in the code:

local success,errcode = pcall(function() pipmak.getimage("test.png") end)

variable success is always true both is test.png exists or not,
and an error message is printed out!!

I would like to have a behaviour like this (in pseudo-code):

    if image1 exists then
      load image1
    else
      load image2
    end

and, off course, without any error message printing!

Should be possible change this in future?

Thank you!

-Andrea


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users

Re: Error handling with pipmak.getimage/pipmak.newimage

by Christian Walther :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrea Viarengo wrote:
> is there a reason why standard lua error handling functions doesn't work with
> pipmak.getimage/pipmak.newimage?

I don't think there is a particular reason, except that it has historically
evolved that way.

> I.e. in the code:
>
> local success,errcode = pcall(function() pipmak.getimage("test.png") end)
>
> variable success is always true both is test.png exists or not,
> and an error message is printed out!!
>
> I would like to have a behaviour like this (in pseudo-code):
>
>     if image1 exists then
>       load image1
>     else
>       load image2
>     end
>
> and, off course, without any error message printing!

I agree that this could be useful.

What's important is that when you write

patch { image = "test.png" }

and test.png doesn't exist, that shouldn't cause the whole node loading
operation to fail, but load the "question mark" image instead and print a
warning. It seems to me that this could still be achieved with a getimage()
that uses standard Lua error handling, so I currently see no reason not to
change it.

 -Christian


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Pipmak-Users mailing list
Pipmak-Users@...
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users