-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
100 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
cardano-cli/src/Cardano/CLI/Types/Errors/PlutusScriptDecodeError.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Types.Errors.PlutusScriptDecodeError | ||
( PlutusScriptDecodeError(..) | ||
) where | ||
|
||
import Cardano.Api | ||
import Data.Text (Text) | ||
|
||
data PlutusScriptDecodeError | ||
= PlutusScriptDecodeErrorUnknownVersion !Text | ||
| PlutusScriptJsonDecodeError !JsonDecodeError | ||
| PlutusScriptDecodeTextEnvelopeError !TextEnvelopeError | ||
| PlutusScriptDecodeErrorVersionMismatch | ||
!Text | ||
-- ^ Script version | ||
!AnyPlutusScriptVersion | ||
-- ^ Attempted to decode with version | ||
|
||
instance Error PlutusScriptDecodeError where | ||
prettyError = \case | ||
PlutusScriptDecodeErrorUnknownVersion version -> | ||
"Unknown Plutus script version: " <> pretty version | ||
PlutusScriptJsonDecodeError err -> | ||
prettyError err | ||
PlutusScriptDecodeTextEnvelopeError err -> | ||
prettyError err | ||
PlutusScriptDecodeErrorVersionMismatch version (AnyPlutusScriptVersion v) -> | ||
"Version mismatch in code: script version that was read" | ||
<> pretty version | ||
<> " but tried to decode script version: " | ||
<> pshow v |
36 changes: 36 additions & 0 deletions
36
cardano-cli/src/Cardano/CLI/Types/Errors/ScriptDataError.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
module Cardano.CLI.Types.Errors.ScriptDataError | ||
( ScriptDataError(..) | ||
, renderScriptDataError | ||
) where | ||
|
||
|
||
|
||
import Cardano.Api | ||
import qualified Cardano.Binary as CBOR | ||
|
||
|
||
data ScriptDataError | ||
= ScriptDataErrorFile (FileError ()) | ||
| ScriptDataErrorJsonParse !FilePath !String | ||
| ScriptDataErrorConversion !FilePath !ScriptDataJsonError | ||
| ScriptDataErrorValidation !FilePath !ScriptDataRangeError | ||
| ScriptDataErrorMetadataDecode !FilePath !CBOR.DecoderError | ||
| ScriptDataErrorJsonBytes !ScriptDataJsonBytesError | ||
deriving Show | ||
|
||
renderScriptDataError :: ScriptDataError -> Doc ann | ||
renderScriptDataError = \case | ||
ScriptDataErrorFile err -> | ||
prettyError err | ||
ScriptDataErrorJsonParse fp jsonErr -> | ||
"Invalid JSON format in file: " <> pshow fp <> "\nJSON parse error: " <> pretty jsonErr | ||
ScriptDataErrorConversion fp sDataJsonErr -> | ||
"Error reading metadata at: " <> pshow fp <> "\n" <> prettyError sDataJsonErr | ||
ScriptDataErrorValidation fp sDataRangeErr -> | ||
"Error validating script data at: " <> pshow fp <> ":\n" <> prettyError sDataRangeErr | ||
ScriptDataErrorMetadataDecode fp decoderErr -> | ||
"Error decoding CBOR metadata at: " <> pshow fp <> " Error: " <> pshow decoderErr | ||
ScriptDataErrorJsonBytes e -> | ||
prettyError e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters