-
Notifications
You must be signed in to change notification settings - Fork 724
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
Render errors as JSON in http response #5545
Conversation
cbd8143
to
bb1e073
Compare
f8d4a96
to
5159934
Compare
5159934
to
9243464
Compare
9243464
to
f4fb982
Compare
d52ca7a
to
ebd5dda
Compare
kind: ShelleyTxValidationError | ||
tag: TxValidationErrorInCardanoMode | ||
tag: TxCmdTxSubmitValidationError | ||
tag: TxSubmitFail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the response that will be returned. The golden file is yaml, but the response will be the JSON equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of yaml vs pretty JSON? My thinking is it's better to be close to the actual output.
ebd5dda
to
9aa39bc
Compare
|
||
newtype TxSubmitPort = TxSubmitPort Int | ||
|
||
-- | The errors that the raw CBOR transaction parsing\/decoding functions can return. | ||
-- | ||
newtype RawCborDecodeError = RawCborDecodeError [DecoderError] | ||
deriving (Eq, Show) | ||
deriving (Eq, Generic, Show) | ||
|
||
instance Error RawCborDecodeError where | ||
prettyError (RawCborDecodeError decodeErrors) = "RawCborDecodeError decode error: " <> pshow (fmap pshow decodeErrors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this instance can be simplified a bit
prettyError (RawCborDecodeError decodeErrors) = "RawCborDecodeError decode error: " <> pshow (fmap pshow decodeErrors) | |
prettyError (RawCborDecodeError decodeErrors) = "RawCborDecodeError decode error:" <+> pshow decodeErrors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instance wasn't added in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coupe of minor comments
@@ -50,34 +57,40 @@ data TxSubmitWebApiError | |||
| TxSubmitBadTx !Text | |||
| TxSubmitFail TxCmdError | |||
|
|||
newtype EnvSocketError = CliEnvVarLookup Text deriving (Eq, Show) | |||
deriving instance Generic TxSubmitWebApiError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we take the time to be explicit about ToJSON TxSubmitWebApiError
. It gives us better control over deprecation handling or in general customizing the output to our liking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can certainly expand this into a manual ToJSON
instance. Do you want the ToJSON
instance to behave like the generic instance or something different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a preference as long as it's explicit
|
||
data TxCmdError | ||
= TxCmdSocketEnvError EnvSocketError | ||
| TxCmdEraConsensusModeMismatch !AnyCardanoEra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constructor is not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. Thanks!
kind: ShelleyTxValidationError | ||
tag: TxValidationErrorInCardanoMode | ||
tag: TxCmdTxSubmitValidationError | ||
tag: TxSubmitFail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of yaml vs pretty JSON? My thinking is it's better to be close to the actual output.
I switch to use pretty JSON. YAML would have some benefit if the JSON string contained newlines, but that might not happen in this case. |
048fac1
to
8fb75ea
Compare
31e2073
to
48f4dbb
Compare
1ec95fa
to
62df968
Compare
867fd60
to
b070859
Compare
b070859
to
9d77edc
Compare
Description
Checklist
See Runnings tests for more details
CHANGELOG.md
for affected package.cabal
files are updatedhlint
. See.github/workflows/check-hlint.yml
to get thehlint
versionstylish-haskell
. See.github/workflows/stylish-haskell.yml
to get thestylish-haskell
versionghc-8.10.7
andghc-9.2.7
Note on CI
If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.