use std::io::Error as IOError;
#[derive(Debug, thiserror::Error)]
#[allow(clippy::large_enum_variant)]
pub enum Error {
#[error("suibase: Not installed. Need to run ~/suibase/install")]
NotInstalled,
#[error("suibase: Workdir not selected. Successful call to `select_workdir` needed")]
WorkdirNotSelected,
#[error(
"suibase: Path could not be access. Check suibase is selecting a valid active workdir"
)]
WorkdirAccessError,
#[error("suibase: Workdir does not exists. Check suibase is selecting a valid active workdir")]
WorkdirNotExists,
#[error("suibase: Not finding keystore `{path:?}`. Run the sui client to create it?")]
SuibaseKeystoreNotExists { path: String },
#[error(
"suibase: No published data found for package `{package_name:?}`.\n\
Note that the package must have been published via `{workdir:?} publish`, and not e.g. the Sui SDK."
)
]
PublishedDataNotFound {
package_name: String,
workdir: String,
path: String,
},
#[error("suibase: Missing link definition. Check suibase.yaml links section.")]
MissingLinkDefinition,
#[error("suibase: Missing at least one link definition. Check suibase.yaml links section.")]
MissingAtLeastOneLinkDefinition,
#[error("suibase: Missing `{url_field:?}` link field. May be a problem with the suibase.yaml link section (1).")]
MissingLinkField { url_field: String },
#[error("suibase: Missing config.yaml. Did you do '{workdir:?} start'?")]
ConfigAccessError { workdir: String },
#[error("suibase: Access problem with config.yaml. Did you do '{workdir:?} start' or run the sui client once?")]
ConfigReadError { workdir: String },
#[error("suibase: Unknown active address. Did you run the sui client at least once?")]
ConfigActiveAddressParseError { address: String },
#[error("suibase: Invalid workdir name (empty string)")]
WorkdirNameEmpty,
#[error("suibase: Invalid package name (empty string)")]
PackageNameEmpty,
#[error("suibase: Invalid address name (empty string)")]
AddressNameEmpty,
#[error("suibase: Invalid object_type parameter with missing field")]
ObjectTypeMissingField,
#[error("suibase: Invalid object_type parameter")]
ObjectTypeInvalidFormat,
#[error("suibase: Not finding address name'{address_name:?}'")]
AddressNameNotFound { address_name: String },
#[error("suibase: Active workdir read of .state/name failed. Try to 'update' the workdir")]
WorkdirStateNameAccessFailed,
#[error(
"suibase: Could not open DNS (client address) file `{path:?}`. Try to 'update' the workdir"
)]
WorkdirStateDNSAccessFailed { path: String },
#[error("suibase: Active workdir .state/name not set. Try to 'update' the workdir")]
WorkdirStateNameNotSet,
#[error("suibase: Invalid package-id.json format")]
PackageIdJsonInvalidFormat,
#[error("suibase: Invalid package id hexadecimal `{id:?}`.")]
PackageIdInvalidHex { id: String },
#[error("suibase: Could not read published new objects file `{path:?}`")]
PublishedNewObjectReadError { path: String },
#[error("suibase: Could not parse published new objects id `{id:?}` from file `{path:?}`")]
PublishedNewObjectParseError { path: String, id: String },
#[error(
"suibase: Workdir not fully initialized. Do '{workdir:?} start' or '{workdir:?} update'"
)]
WorkdirInitializationIncomplete { workdir: String },
#[error("suibase: Could not read dns file `{path:?}`")]
WorkdirStateDNSReadError { path: String },
#[error("suibase: Could not parse dns address `{address:?}` from file `{path:?}`")]
WorkdirStateDNSParseError { path: String, address: String },
#[error(
"suibase: [code:1] Could not open published data `{path:?}`.\n\
IO Error: {io_error:?}\
Was the package `{package_name:?}` published with success?",
)
]
PublishedDataAccessError { package_name: String, path: String, io_error: IOError },
#[error("suibase: [code:2] Could not open published data `{path:?}`. Symlink value is `{symlink_target:?}`. Was the package `{package_name:?}` published with success?")]
PublishedDataAccessErrorInvalidSymlink {
package_name: String,
path: String,
symlink_target: String,
},
#[error("suibase: [code:3] Could not open published data `{path:?}`. Was the package `{package_name:?}` published with success?")]
PublishedDataAccessErrorSymlinkNotFound { package_name: String, path: String },
#[error("suibase: Could not open published new objects file `{path:?}`. Was the package published with success?")]
PublishedNewObjectAccessError { path: String },
#[error("suibase: Could not read link file `{path:?}`")]
WorkdirStateLinkReadError { path: String },
#[error("suibase: Workdir name not set. Internal error. Contact developer")]
WorkdirNameNotSet,
#[error("suibase: Workdir path not set. Internal error. Contact developer")]
WorkdirPathNotSet,
#[error("suibase: Invalid file name (empty string)")]
FileNameEmpty,
#[error("suibase: Invalid state name (empty string)")]
StateNameEmpty,
}