Make dberr.Error thread-safe.

Today I learned that the initial error mechanism that I wrote for tiedot isn't treadsafe and multiple goroutiens calling `dberr.Error.Error()` would result in a race and ended up with a crash.

I have refactored the code to make it threadsafe.


I have also refactored out the `dberr.Error.Code` as it seem pretty redundent to me. If you think they can be helpful, It should be very easy to reintroduce them and add a `dberr.Code(e error) int` to handle them similar to `dberr.Type`.


Please revivew the code and let me know if anything can be improved.