[Clam-devel] Error Handling with Types

Pau Arumí parumi at iua.upf.edu
Wed May 21 01:19:50 PDT 2008


On dt, 2008-05-20 at 20:02 -0300, Francisco Tufró wrote:
> Hi, i have almost finished the Link test.
> I have this question:
> How do i (or what do i do to) handle errors with these functions, in
> the first what should i do? make the function bool and return true if
> it was connected?? or throw something with a special error class that
> i ignore?

Let's take the restrictive and easier path: just assert in the error
case. Like we do in Ports. I say it's easier because we avoid dealing
with exception handling.
OutPort.hxx line 175

And (doxygen) document this behavior, and explaining that before calling
Link the user must check the likability with IsLinkable

See ports unit tests for an example of how to test that an assert is
triggered.

Pau



> 
>        void BaseTypedOutControl::Link(BaseTypedInControl& in)
>        {
>                if(IsLinkable(in)){
>                        DoTypedLink(in);
>                }
>                /* Throw error with else! ? */
>        }
> 
> and: 
> 
>     template<class TypedControlData>
>     void
> TypedOutControl<TypedControlData>::DoTypedLink(BaseTypedInControl& in)
>     {
>         AddLink(dynamic_cast< ProperTypedInControl& >(in));
>     }
> 
> by the way i send the patch so you have the full code.
> bye!
> Francisco
> 
> _______________________________________________
> Clam-devel mailing list
> Clam-devel at llistes.projectes.lafarga.org
> https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel





More information about the clam-devel mailing list