msgpack/msgpack-d — pull request #2 by AndrejMitrovic (2012-11-10 14:31:39+00:00)
Title: Add error message when toMsgpack/fromMsgpack fail to instantiate

This adds a check whether `toMsgpack` or `fromMsgpack` exist before attempting to call `__traits(compiles` on them. If the function doesn't exist, `Packer` uses its own serialize/unserialize routine. But if the functions exist but fail to instatiate the user gets an error message.

Example:

```D
import msgpack;

struct Struct
{
void toMsgpack()() { }
void fromMsgpack()() { }
}

class Class
{
void toMsgpack()() { }
void fromMsgpack()() { }
}

void main()
{
Struct s;
auto c = new Class;

ubyte[] data = msgpack.pack(s); // case 1
ubyte[] data = msgpack.pack(c); // case 2

msgpack.unpack(data, s); // case 3
msgpack.unpack(data, c); // case 4
}
```

Errors:

Case 1:

```
msgpack.d(819): Error: static assert "Failed to invoke 'toMsgpack' on type 'Struct'"
msgpack.d(4084): instantiated from here: pack!(const(Struct))
test.d(22): instantiated from here: pack!(false,Struct)
```

Case 2:

```
msgpack.d(775): Error: static assert "Failed to invoke 'toMsgpack' on type 'Class'"
msgpack.d(4084): instantiated from here: pack!(Class)
test.d(23): instantiated from here: pack!(false,Class)
```

Case 3:

```
msgpack.d(2069): Error: static assert "Failed to invoke 'fromMsgpack' on type 'Struct'"
msgpack.d(4145): instantiated from here: unpack!(Struct)
test.d(25): instantiated from here: unpack!(Struct)
```

Case 4:

```
msgpack.d(2033): Error: static assert "Failed to invoke 'fromMsgpack' on type 'Class'"
msgpack.d(4145): instantiated from here: unpack!(Class,)
test.d(26): instantiated from here: unpack!(Class)
```