[ymeng] Move db exception to database package
[ymeng] Move declaration closer to usage