[Mono-list] Using Exceptions with external Plugins

Pablo Fischer pablo@pablo.com.mx
Tue, 29 Jun 2004 09:48:10 -0500


--=-Cb/u6renAVsJVo0r5nJl
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: quoted-printable

Thanks!

However, I think the best idea is to use generic Exceptions, if I try to
use the CookComputing.XmlRpc Exceptions I need to compile ALL my
application with CookComputing.dll and I'm not looking that, that's why
I'm working with plugins to just compile CookComputing.XmlRpc in the
plugins and not in all the application.

Thanks for these suggestions!
Pablo


El mar, 29-06-2004 a las 09:06, Arild Fines escribi=F3:
> mono-list-admin@lists.ximian.com wrote:
> > Cool! Thanks!
> >
> > Now, how can I get sure that the InnerException is a
> > XmlRpcFaultException or a XmlRpcMissedSomething?, I'm trying with this:
> >
> > } catch(TargetInvocationException e) {
> >    if(e.InnerException.GetType().ToString() =3D=3D
> > "CookComputing.XmlRpc.XmlRpcFaultException") {
> >    Console.WriteLine("yes");
> > }
> >
> > But I don't think it's the correct way/code, any suggestions?
>=20
> You might want to take advantage of the fact that Type.InvokeMember actua=
lly
> performs virtual dispatch based on the runtime type of the object *AND* a=
ll
> of the parameters, IE, it performs double/triple/ntuple dispatch.
>=20
> That means the following will work the way you want it to:
>=20
> catch( TargetInvocationException e )
> {
> 	Type t =3D this.GetType();
> 	t.InvokeMember( "HandleException", BindingFlags.InvokeMethod |
> 		BindingFlags.Instance | BindingFlags.NonPublic, null,
>             this, new object[]{ e } );
> }
>=20
> // ...
>=20
> private void HandleException( CookComputing.XmlRpc.XmlRpcFaultException e=
 )
> {
>    //...
> }
>=20
> private void HandleException( FooException e )
> {
>    //...
> }
>=20
> private void HandleException( Exception e )
> {
>    // called if there are no other matching signatures
> }
>=20
> Of course, it isn't particularly fast...
>=20
> --
> Arild
>=20
> AnkhSVN: http://ankhsvn.tigris.org
> Blog: http://ankhsvn.com/blog
> IRC: irc://irc.freenode.net/ankhsvn
>=20
> "Weaseling out of things is good. It's what separates us from the other
> animals....except weasels." -- Homer Simpson
--=20
Pablo Fischer Sandoval (pablo [arroba/at] pablo.com.mx)
Fingerprint:  5973 0F10 543F 54AE 1E41  EC81 0840 A10A 74A4 E5C0
http://www.pablo.com.mx=20
http://www.debianmexico.org

--=-Cb/u6renAVsJVo0r5nJl
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada
	digitalmente

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQBA4YEpCEChCnSk5cARArtcAJ4nVCuu/G9/CI8gWqOuqOtP7i/0uwCdGvZg
uu4bWjs8TiUOSk1F+00yemA=
=TNXQ
-----END PGP SIGNATURE-----

--=-Cb/u6renAVsJVo0r5nJl--