Thread: [java-gnome-hackers] Should Pixbuf constructor propegate unchecked excpetion for unknown format?
Brought to you by:
afcowie
From: Andrew C. <an...@op...> - 2008-06-16 09:43:41
|
The checkPixbuf*() methods used by the Pixbuf constructors take the GError and wrap it in an unchecked RuntimeException. These crop up when, for one example, there is an "Unrecognized image file format". That certainly shouldn't be so vague as a RuntimeException, and now that I'm running into them I'm not entirely convinced it should be unchecked. So, checked or unchecked? And, which particular exception for this case? If checked, IOException? If unchecked, the ever-trusty IllegalArgumentException? [This is another instance where the lack of specificity of our wrapping GError is turning up. I have a feeling we need to start passing some identifiers or Constants through with error domain and the specific error enum so that the Java side code can, when the error is understandable, raise something a bit more appropriate] AfC Sydney -- Andrew Frederick Cowie Operational Dynamics is an operations and engineering consultancy focusing on IT strategy, organizational architecture, systems review, and effective procedures for change management. We actively carry out research and development in these areas on behalf of our clients, and enable successful use of open source in their mission critical enterprises, worldwide. http://www.operationaldynamics.com/ Sydney New York Toronto London |
Re: [java-gnome-hackers] Should Pixbuf constructor propegate
unchecked excpetion for unknown format?
From: Vreixo F. L. <met...@ya...> - 2008-06-16 10:03:50
|
Hi! --- Em seg, 16/6/08, Andrew Cowie <an...@op...> escreveu: > These crop up when, for one example, there is an > "Unrecognized image > file format". That certainly shouldn't be so vague > as a > RuntimeException, and now that I'm running into them > I'm not entirely > convinced it should be unchecked. > > So, checked or unchecked? And, which particular exception > for this case? > If checked, IOException? If unchecked, the ever-trusty > IllegalArgumentException? Good question. The fast answer: if only programmer errors can lead to that exception, then unchecked, On the other side, if the user interaction can cause such exception, then checked, to forced programmers to catch it and report it to the user. The problem is that, in my apps, I always use Pixbuf for UI images that are packaged together with the application. Thus, this fits in the first case (programmer errors, maybe configuration errors in this case), and thus unchecked seems better. However, I wonder if somebody may be using Pixbuf for load images supplied by user, For example, an image viewer or picture catalog image may use Pixbuf for that. In those case checked is better. > > [This is another instance where the lack of specificity of > our wrapping > GError is turning up. I have a feeling we need to start > passing some > identifiers or Constants through with error domain and the > specific > error enum so that the Java side code can, when the error > is > understandable, raise something a bit more appropriate] Yes, that's a thing I've planned. The error code needs to be exposed, together with [at least] the most common error codes, as enums. Maybe just as static fields of GlibException. I can take care of this next days (I'm a bit busy, as always, but...). Cheers Vreixo Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento! http://br.mail.yahoo.com/ |
Re: [java-gnome-hackers] Should Pixbuf constructor
propegate unchecked excpetion for unknown format?
From: Andrew C. <an...@op...> - 2008-06-16 12:31:59
|
On Mon, 2008-06-16 at 10:01 +0000, Vreixo Formoso Lopes wrote: > However, I wonder if somebody may be using Pixbuf for load images > supplied by user, For example, an image viewer or picture catalog > image may use Pixbuf for that. In those case checked is better. Yes, that is the case I am presently encountering. While I agree that images being loaded are under the control of the programmer is a common scenario, loading foreign images would have to be as common if not more so. > Yes, that's a thing I've planned. The error code needs to be exposed, > together with [at least] the most common error codes, as enums. It's not even a matter of "common" so much as it is "encountered". [Also, keep in mind that the Constants need to be registered, but there is nothing that says they need to be public. The typed Exception being thrown takes care of that] AfC Sydney |
Re: [java-gnome-hackers] Should Pixbuf constructor propegate
unchecked excpetion for unknown format?
From: Vreixo F. L. <met...@ya...> - 2008-06-16 15:46:07
|
--- Em seg, 16/6/08, Andrew Cowie <an...@op...> escreveu: > [Also, keep in mind that the Constants need to be > registered, but there > is nothing that says they need to be public. The typed > Exception being > thrown takes care of that] mmm, I thinking about a [maybe better] alternative. Currently for functions that take a GError* we throw a GlibException from JNI side when needed. Maybe we can create our own hierarchy based on GlibException, and modify the JNI code to throw the speficic exception based on the GError code. As long as GError codes are unique along all functions -Am I right?-, this simplifies the implementation of new coverage. Cheers Vreixo Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento! http://br.mail.yahoo.com/ |
Re: [java-gnome-hackers] Should Pixbuf constructor
propegate unchecked excpetion for unknown format?
From: Andrew C. <an...@op...> - 2008-06-17 02:16:18
|
On Mon, 2008-06-16 at 15:45 +0000, Vreixo Formoso Lopes wrote: > mmm, I thinking about a [maybe better] alternative. Currently for > functions that take a GError* we throw a GlibException from JNI side > when needed. Maybe we can create our own hierarchy based on > GlibException, and modify the JNI code to throw the speficic exception > based on the GError code. That would be overkill. AfC Sydney |
Re: [java-gnome-hackers] Should Pixbuf constructor propegate
unchecked excpetion for unknown format?
From: Vreixo F. L. <met...@ya...> - 2008-06-17 13:40:41
|
--- Em ter, 17/6/08, Andrew Cowie <an...@op...> escreveu: > On Mon, 2008-06-16 at 15:45 +0000, Vreixo Formoso Lopes > wrote: > > mmm, I thinking about a [maybe better] alternative. > Currently for > > functions that take a GError* we throw a GlibException > from JNI side > > when needed. Maybe we can create our own hierarchy > based on > > GlibException, and modify the JNI code to throw the > speficic exception > > based on the GError code. > > That would be overkill. No really... we only need to expose exceptions we really need. As a future task, we can even modify the codegen and .defs data to report (as a throws WhateverException) the exceptions a concrete method can throw... Cheers Vreixo Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento! http://br.mail.yahoo.com/ |
Re: [java-gnome-hackers] Should Pixbuf constructor
propegate unchecked excpetion for unknown format?
From: Andrew C. <an...@op...> - 2008-06-18 12:13:01
|
On Tue, 2008-06-17 at 13:39 +0000, Vreixo Formoso Lopes wrote: > > That would be overkill. > > No really... we only need to expose exceptions we really need. As a > future task, we can even modify the codegen and .defs data to report > (as a throws WhateverException) the exceptions a concrete method can > throw... Don't do that. You'd have to do add FindClass() on the JNI side for each Exception you'd created. And further, if it's "file not found" then the right Exception will be FileNotFoundException. Etc. Keep it on the Java side. AfC Sydney |