core: use error wrapping to provide more details

This commit is contained in:
Roman Khimov 2020-08-06 18:34:44 +03:00
parent 5ef08f60ae
commit 205f52c563
4 changed files with 18 additions and 18 deletions

View file

@ -917,8 +917,8 @@ func (s *Server) submitBlock(reqParams request.Params) (interface{}, *response.E
}
err = s.chain.AddBlock(b)
if err != nil {
switch err {
case core.ErrInvalidBlockIndex, core.ErrAlreadyExists:
switch {
case errors.Is(err, core.ErrInvalidBlockIndex) || errors.Is(err, core.ErrAlreadyExists):
return nil, response.ErrAlreadyExists
default:
return nil, response.ErrValidationFailed