Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Extract inline (http and client) errors to errors.go #967

Merged
merged 7 commits into from
Dec 15, 2022

Conversation

AndrewSisley
Copy link
Contributor

Relevant issue(s)

Part of #257

Description

Extracts inline errors to package errors.go for the http and client packages, and a couple of the ones in cli (see commit message for more info there).

My gut is staying to chunk this up into multiple PRs, but I dont want to spam you guys on a per-package basis. Will likely be doing this in 2-3 package chunks - do let me know your thoughts on this, the commits will be per package anyway, and the PRs will likely be based of one another so it doesnt really affect me personally too much one way or the other (minus any conflicts from larger merge-latency with larger PRs).

@AndrewSisley AndrewSisley added area/errors Related to the internal management or design of our error handling system action/no-benchmark Skips the action that runs the benchmark. labels Dec 14, 2022
@AndrewSisley AndrewSisley added this to the DefraDB v0.4 milestone Dec 14, 2022
@AndrewSisley AndrewSisley requested a review from a team December 14, 2022 17:14
@AndrewSisley AndrewSisley self-assigned this Dec 14, 2022
@codecov
Copy link

codecov bot commented Dec 14, 2022

Codecov Report

Merging #967 (f6bc237) into develop (7b6ee3b) will decrease coverage by 0.09%.
The diff coverage is 24.19%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #967      +/-   ##
===========================================
- Coverage    59.95%   59.86%   -0.10%     
===========================================
  Files          157      157              
  Lines        17687    17716      +29     
===========================================
+ Hits         10604    10605       +1     
- Misses        6129     6157      +28     
  Partials       954      954              
Impacted Files Coverage Δ
api/http/errors.go 100.00% <ø> (ø)
cli/addreplicator.go 5.12% <0.00%> (ø)
cli/blocks_get.go 4.44% <0.00%> (ø)
cli/errors.go 0.00% <0.00%> (ø)
client/dockey.go 51.16% <0.00%> (ø)
client/document.go 64.25% <0.00%> (ø)
db/subscriptions.go 57.14% <0.00%> (ø)
client/errors.go 60.00% <50.00%> (-40.00%) ⬇️
api/http/handlerfuncs.go 85.44% <80.00%> (ø)
api/http/handler.go 100.00% <100.00%> (ø)
... and 2 more

@AndrewSisley AndrewSisley changed the title chore: Extract inline errors to package errors.go (http and client) chore: Extract inline errors to package errors.go (http+client) Dec 14, 2022
@AndrewSisley AndrewSisley changed the title chore: Extract inline errors to package errors.go (http+client) chore: Extract inline errors to errors.go (http+client) Dec 14, 2022
@AndrewSisley AndrewSisley changed the title chore: Extract inline errors to errors.go (http+client) chore: Extract inline (http and client) errors to errors.go Dec 14, 2022
@AndrewSisley AndrewSisley changed the title chore: Extract inline (http and client) errors to errors.go chore: Extract inline (http and client) errors to errors.go Dec 14, 2022
@fredcarle
Copy link
Collaborator

Splitting it up in multiple PRs is a good idea 👍

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just a nitpick and a minor suggestion.

ErrNoListener = errors.New("cannot serve with no listener")
ErrSchema = errors.New("base must start with the http or https scheme")
ErrDatabaseNotAvailable = errors.New("no database available")
ErrXFormNotSupported = errors.New("content type application/x-www-form-urlencoded not yet supported")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: The X can be removed in the name.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks -wasnt sure what I could chop here

  • drop X

@@ -21,9 +21,19 @@ import (

var env = os.Getenv("DEFRA_ENV")

// Errors returnable from this package.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Putting this here because I can't comment directly on the import. I think it would be a good idea to use Defra's errors package instead of the stdlib one so that we can benefit from stacktraces.

Copy link
Contributor Author

@AndrewSisley AndrewSisley Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

! good spot, I didnt notice - should definately be using our errors. Thanks

  • use our errors

I realized that continuing this in this package would be ineffiecient as Orpheus is reworking it at the moment.  He said (without seeing these changes) that it was still useful and shouldnt clash too hard, but I think it would be better to wait a bit to do the rest of the package.
@AndrewSisley AndrewSisley force-pushed the sisley/chore/I257-errors-go branch from 0ebc396 to f6bc237 Compare December 14, 2022 23:51
@AndrewSisley AndrewSisley merged commit 5eb6dbc into develop Dec 15, 2022
@AndrewSisley AndrewSisley deleted the sisley/chore/I257-errors-go branch December 15, 2022 00:22
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
…twork#967)

* Move unexpected type error to client

* Make existing http errors public

* Extract http errors to errors.go

* Extract some cli errors

* Extract client errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/errors Related to the internal management or design of our error handling system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants