// translate looks for certain error types and transforms
// them into web errors. We are losing the trace when this
// error is converted. But we don't log traces for these.
translate looks for certain error types and transforms
them into web errors. We are losing the trace when this
error is converted. But we don't log traces for these.
// translate looks for certain error types and transforms // them into web errors . We are losing the trace when this // error is converted . But we don ' t log traces for these .
func translate(err error) error {
	switch errors.Cause(err) {
	case user.ErrNotFound, product.ErrNotFound:
		return web.ErrNotFound
	case user.ErrInvalidID, product.ErrInvalidID:
		return web.ErrInvalidID
	case user.ErrAuthenticationFailure:
		return web.ErrUnauthorized
	case user.ErrForbidden:
		return web.ErrForbidden
	}
	return err
}
func translate ( err error ) error { switch errors . Cause ( err ) { case user . ErrNotFound , product . ErrNotFound : return web . ErrNotFound case user . ErrInvalidID , product . ErrInvalidID : return web . ErrInvalidID case user . ErrAuthenticationFailure : return web . ErrUnauthorized case user . ErrForbidden : return web . ErrForbidden } return err }
translate looks for certain error types and transforms
them into web errors.
translate looks for certain error types and transforms them into web errors .