Unstructured and ambiguous gosdk errors
- Dominant language
- Go
- Stars
- 30
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
We have errors [repo](https://github.com/0chain/errors). Its error format is:
```
type Error struct {
Code string `json:"code,omitempty"`
Msg string `json:"msg"`
}
```
In gosdk this structure should be used everywhere possible especially when it comes to response gosdk gives to other tools that is using it. Somewhere golang's standard errors package is used, somewhere errors.Throw is used, somewhere above structure is used.
Improper error response should be modified too. For example, on downloadFile function, if all blobbers returns error response then error returned by gosdk is `File content didn't match with the content uploaded`. We can't make anything out of it as it is ambiguous.
This inconsistency makes it harder to handle errors for tools using gosdk.
Please also check for [draft PR](https://github.com/0chain/gosdk/pull/343). Having constants as error code is standard practice.
We can take references from popular repos.
1. https://github.com/minio/minio/blob/master/cmd/api-errors.go
Contributor guide
No contributing guide indexed for this repository
Research direction
Review the linked draft PR #343 and the errors repo to understand the Error struct. Search the gosdk codebase for error returns, especially in downloadFile and similar functions. Identify where standard errors or errors.Throw are used instead of the structured format. The goal is to replace ambiguous error messages with structured errors containing codes and clear messages, referencing the minio example for patterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend, devtools
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100