Documentation
¶
Index ¶
- Constants
- Variables
- func Is(err error, errorCode string) bool
- func IsErrorType(err error, code string) bool
- func Wrapf(err error, format string, args ...interface{}) error
- type Error
- func (e *Error) AddAPIMethod(endpoint string) *Error
- func (e *Error) AddDetail(detail ErrorDetail) *Error
- func (e *Error) AppendMessage(message string) *Error
- func (e *Error) AppendRemediation(remediationMsg string) *Error
- func (e *Error) Error() string
- func (e *Error) Unwrap() error
- func (e *Error) WithCode(code string) *Error
- func (e *Error) WithDetails(details ErrorDetails) *Error
- func (e *Error) WithMessage(msg string, args ...interface{}) *Error
- func (e *Error) WithRemediation(remediationMsg string, args ...interface{}) *Error
- func (e *Error) WithRootCause(err error) *Error
- type ErrorDetail
- type ErrorDetails
- type Warning
- type Warnings
Constants ¶
const ( ErrAccessDenied = "access_denied" ErrAddAppToProject = "add_app_to_project_error" ErrAlreadyLoggedOut = "already_logged_out" ErrAlreadyResolved = "already_resolved" ErrAppsList = "apps_list_error" ErrAppAdd = "app_add_error" ErrAppApprovalRequestDenied = "app_approval_request_denied" ErrAppApprovalRequestEligible = "app_approval_request_eligible" ErrAppApprovalRequestPending = "app_approval_request_pending" ErrAppAuthTeamMismatch = "app_auth_team_mismatch" ErrAppCreate = "app_create_error" ErrAppDelete = "app_delete_error" ErrAppDeploy = "app_deploy_error" ErrAppDeployNotSlackHosted = "app_deploy_function_runtime_not_slack" ErrAppDirectoryAccess = "app_directory_access_error" ErrAppDirOnlyFail = "app_dir_only_fail" ErrAppExists = "app_add_exists" ErrAppFlagRequired = "app_flag_required" ErrAppFound = "app_found" ErrAppHosted = "app_hosted" ErrAppInstall = "app_install_error" ErrAppManifestAccess = "app_manifest_access_error" ErrAppManifestCreate = "app_manifest_create_error" ErrAppManifestGenerate = "app_manifest_generate_error" ErrAppManifestUpdate = "app_manifest_update_error" ErrAppManifestValidate = "app_manifest_validate_error" ErrAppNotEligible = "app_not_eligible" ErrAppNotInstalled = "app_not_installed" ErrAppNotFound = "app_not_found" ErrAppNotHosted = "app_not_hosted" ErrAppRemove = "app_remove_error" ErrAppRenameApp = "app_rename_app" ErrAuthProdTokenNotFound = "auth_prod_token_not_found" ErrAuthTimeout = "auth_timeout_error" ErrAuthToken = "auth_token_error" ErrAuthVerification = "auth_verification_error" ErrBotInviteRequired = "bot_invite_required" // Slack API error code ErrCannotAbandonApp = "cannot_abandon_app" ErrCannotAddOwner = "cannot_add_owner" ErrCannotCountOwners = "cannot_count_owners" ErrCannotDeleteApp = "cannot_delete_app" ErrCannotListCollaborators = "cannot_list_collaborators" ErrCannotListOwners = "cannot_list_owners" ErrCannotRemoveCollaborators = "cannot_remove_collaborators" ErrCannotRemoveOwners = "cannot_remove_owner" ErrCannotRevokeOrgBotToken = "cannot_revoke_org_bot_token" ErrConnectorApprovalPending = "connector_approval_pending" ErrConnectorApprovalRequired = "connector_approval_required" ErrConnectorDenied = "connector_denied" ErrConnectorNotInstalled = "connector_not_installed" ErrChannelNotFound = "channel_not_found" ErrCLIAutoUpdate = "cli_autoupdate_error" ErrCLIConfigLocationError = "cli_config_location_error" ErrCLIConfigInvalid = "cli_config_invalid" ErrCLIReadError = "cli_read_error" ErrCLIUpdateRequired = "cli_update_required" // Slack API error code ErrCommentRequired = "comment_required" ErrConnectedOrgDenied = "connected_org_denied" ErrConnectedTeamDenied = "connected_team_denied" ErrContextValueNotFound = "context_value_not_found" ErrCredentialsNotFound = "credentials_not_found" ErrCustomizableInputMissingMatchingWorkflowInput = "customizable_input_missing_matching_workflow_input" ErrCustomizableInputsNotAllowedOnOptionalInputs = "customizable_inputs_not_allowed_on_optional_inputs" ErrCustomizableInputsOnlyAllowedOnLinkTriggers = "customizable_inputs_only_allowed_on_link_triggers" ErrCustomizableInputUnsupportedType = "customizable_input_unsupported_type" ErrDatastore = "datastore_error" ErrDatastoreMissingPrimaryKey = "datastore_missing_primary_key" ErrDatastoreNotFound = "datastore_not_found" ErrDefaultAppAccess = "default_app_access_error" ErrDefaultAppSetting = "default_app_setting_error" ErrDenoNotFound = "deno_not_found" ErrDeployedAppNotSupported = "deployed_app_not_supported" ErrDocumentationGenerationFailed = "documentation_generation_failed" ErrEnterpriseNotFound = "enterprise_not_found" ErrFailedAddingCollaborator = "failed_adding_collaborator" ErrFailedCreatingApp = "failed_creating_app" ErrFailedDatastoreOperation = "failed_datastore_operation" ErrFailedExport = "failed_export" ErrFailForSomeRequests = "failed_for_some_requests" ErrFailedToGetUser = "failed_to_get_user" ErrFailedToSaveExtensionLogs = "failed_to_save_extension_logs" ErrFailToGetTeamsForRestrictedUser = "fail_to_get_teams_for_restricted_user" ErrFeedbackNameInvalid = "feedback_name_invalid" ErrFeedbackNameRequired = "feedback_name_required" ErrFileRejected = "file_rejected" ErrForbiddenTeam = "forbidden_team" ErrFreeTeamNotAllowed = "free_team_not_allowed" ErrFunctionBelongsToAnotherApp = "function_belongs_to_another_app" ErrFunctionNotFound = "function_not_found" ErrGitNotFound = "git_not_found" ErrGitClone = "git_clone_error" ErrGitZipDownload = "git_zip_download_error" ErrHomeDirectoryAccessFailed = "home_directory_access_failed" ErrHooksJSONLocation = "hooks_json_location_error" ErrHostAppsDisallowUserScopes = "hosted_apps_disallow_user_scopes" ErrHTTPRequestFailed = "http_request_failed" ErrHTTPResponseInvalid = "http_response_invalid" ErrInsecureRequest = "insecure_request" ErrInstallationDenied = "installation_denied" ErrInstallationFailed = "installation_failed" ErrInstallationRequired = "installation_required" ErrInternal = "internal_error" ErrInvalidApp = "invalid_app" ErrInvalidAppDirectory = "invalid_app_directory" ErrInvalidAppFlag = "invalid_app_flag" ErrInvalidAppID = "invalid_app_id" ErrInvalidArgs = "invalid_args" ErrInvalidArgumentsCustomizableInputs = "invalid_arguments_customizable_inputs" ErrInvalidArguments = "invalid_arguments" ErrInvalidAuth = "invalid_auth" ErrInvalidChallenge = "invalid_challenge" ErrInvalidChannelID = "invalid_channel_id" ErrInvalidCursor = "invalid_cursor" ErrInvalidDistributionType = "invalid_distribution_type" ErrInvalidFlag = "invalid_flag" ErrInvalidInteractiveTriggerInputs = "invalid_interactive_trigger_inputs" ErrInvalidManifest = "invalid_manifest" ErrInvalidManifestSource = "invalid_manifest_source" ErrInvalidParameters = "invalid_parameters" ErrInvalidPermissionType = "invalid_permission_type" ErrInvalidRefreshToken = "invalid_refresh_token" ErrInvalidRequestID = "invalid_request_id" ErrInvalidResourceID = "invalid_resource_id" ErrInvalidResourceType = "invalid_resource_type" ErrInvalidS3Key = "invalid_s3_key" ErrInvalidScopes = "invalid_scopes" ErrInvalidSemVer = "invalid_semver" ErrInvalidSlackProjectDirectory = "invalid_slack_project_directory" ErrInvalidDatastore = "invalid_datastore" ErrInvalidDatastoreExpression = "invalid_datastore_expression" ErrInvalidToken = "invalid_token" ErrInvalidTrigger = "invalid_trigger" ErrInvalidTriggerAccess = "invalid_trigger_access" ErrInvalidTriggerConfig = "invalid_trigger_config" ErrInvalidTriggerEventType = "invalid_trigger_event_type" ErrInvalidTriggerInputs = "invalid_trigger_inputs" ErrInvalidTriggerType = "invalid_trigger_type" ErrInvalidUserID = "invalid_user_id" ErrInvalidWebhookConfig = "invalid_webhook_config" ErrInvalidWebhookSchemaRef = "invalid_webhook_schema_ref" ErrInvalidWorkflowAppID = "invalid_workflow_app_id" ErrInvalidWorkflowID = "invalid_workflow_id" ErrIsRestricted = "is_restricted" ErrLocalAppNotFound = "local_app_not_found" ErrLocalAppNotSupported = "local_app_not_supported" ErrLocalAppRemoval = "local_app_removal_error" ErrLocalAppRun = "local_app_run_error" ErrLocalAppRunCleanExit = "local_app_run_clean_exit" ErrMethodNotSupported = "method_not_supported" ErrMismatchedFlags = "mismatched_flags" ErrMissingAppID = "missing_app_id" ErrMissingAppTeamID = "missing_app_team_id" ErrMissingChallenge = "missing_challenge" ErrMissingExperiment = "missing_experiment" ErrMissingFunctionIdentifier = "missing_function_identifier" ErrMissingFlag = "missing_flag" ErrMissingInput = "missing_input" ErrMissingOptions = "missing_options" ErrMissingScope = "missing_scope" ErrMissingScopes = "missing_scopes" ErrMissingUser = "missing_user" ErrMissingValue = "missing_value" ErrNotAuthed = "not_authed" ErrNotBearerToken = "not_bearer_token" ErrNotFound = "not_found" ErrNoFile = "no_file" ErrNoPendingRequest = "no_pending_request" ErrNoPermission = "no_permission" ErrNoTokenFound = "no_token_found" ErrNoTriggers = "no_triggers" ErrNoValidNamedEntities = "no_valid_named_entities" ErrOrgNotConnected = "org_not_connected" ErrOrgNotFound = "org_not_found" ErrOrgGrantExists = "org_grant_exists" ErrOSNotSupported = "os_not_supported" ErrOverResourceLimit = "over_resource_limit" ErrParameterValidationFailed = "parameter_validation_failed" ErrProcessInterrupted = "process_interrupted" ErrProjectCompilation = "project_compilation_error" ErrProjectConfigIDNotFound = "project_config_id_not_found" ErrProjectConfigManifestSource = "project_config_manifest_source_error" ErrProjectFileUpdate = "project_file_update_error" ErrProviderNotFound = "provider_not_found" ErrPrompt = "prompt_error" ErrPublishedAppOnly = "published_app_only" ErrRequestIDOrAppIDIsRequired = "request_id_or_app_id_is_required" ErrRatelimited = "ratelimited" ErrRestrictedPlanLevel = "restricted_plan_level" ErrRuntimeNotFound = "runtime_not_found" ErrRuntimeNotSupported = "runtime_not_supported" ErrSDKConfigLoad = "sdk_config_load_error" ErrSDKHookInvocationFailed = "sdk_hook_invocation_failed" ErrSDKHookNotFound = "sdk_hook_not_found" ErrSampleCreate = "sample_create_error" ErrServiceLimitsExceeded = "service_limits_exceeded" ErrSlackAuth = "slack_auth_error" ErrSlackJSONLocation = "slack_json_location_error" ErrSlackSlackJSONLocation = "slack_slack_json_location_error" ErrSocketConnection = "socket_connection_error" ErrScopesExceedAppConfig = "scopes_exceed_app_config" ErrStreamingActivityLogs = "streaming_activity_logs_error" ErrSurveyConfigNotFound = "survey_config_not_found" ErrSystemConfigIDNotFound = "system_config_id_not_found" ErrSystemRequirementsFailed = "system_requirements_failed" ErrTeamAccessNotGranted = "team_access_not_granted" ErrTeamFlagRequired = "team_flag_required" ErrTeamList = "team_list_error" ErrTeamNotConnected = "team_not_connected" ErrTeamNotFound = "team_not_found" ErrTeamNotOnEnterprise = "team_not_on_enterprise" ErrTeamQuotaExceeded = "team_quota_exceeded" ErrTemplatePathNotFound = "template_path_not_found" ErrTokenExpired = "token_expired" ErrTokenRevoked = "token_revoked" ErrTokenRotation = "token_rotation_error" ErrTooManyCustomizableInputs = "too_many_customizable_inputs" ErrTooManyIdsProvided = "too_many_ids_provided" ErrTooManyNamedEntities = "too_many_named_entities" ErrTriggerCreate = "trigger_create_error" ErrTriggerDelete = "trigger_delete_error" ErrTriggerDoesNotExist = "trigger_does_not_exist" ErrTriggerNotFound = "trigger_not_found" ErrTriggerUpdate = "trigger_update_error" ErrUnableToDelete = "unable_to_delete" ErrUnableToOpenFile = "unable_to_open_file" ErrUnableToParseJSON = "unable_to_parse_json" ErrUninstallHalted = "uninstall_halted" ErrUnknownFileType = "unknown_file_type" ErrUnknownFunctionID = "unknown_function_id" ErrUnknownMethod = "unknown_method" ErrUnknownWebhookSchemaRef = "unknown_webhook_schema_ref" ErrUnknownWorkflowID = "unknown_workflow_id" ErrUntrustedSource = "untrusted_source" ErrUnsupportedFileName = "unsupported_file_name" ErrUserAlreadyOwner = "user_already_owner" ErrUserAlreadyRequested = "user_already_requested" ErrUserCannotManageApp = "user_cannot_manage_app" ErrUserIDIsRequired = "user_id_is_required" ErrUserNotFound = "user_not_found" ErrUserRemovedFromTeam = "user_removed_from_team" ErrWorkflowNotFound = "workflow_not_found" ErrYaml = "yaml_error" )
const MaxRecursiveErrDepth = 20
Variables ¶
var ErrorCodeMap = map[string]Error{}/* 242 elements not displayed */
var ErrorMessageMap = errorMessageMap()
Functions ¶
func IsErrorType ¶
IsErrorType returns true if the given error is of the type represented by the given error code
Types ¶
type Error ¶
type Error struct {
Code string `json:"code,omitempty"`
Message string `json:"error,omitempty"`
Description string `json:"slack_cli_error_description,omitempty"`
Remediation string `json:"remediation,omitempty"`
Details ErrorDetails `json:"errors,omitempty"`
Cause error // TODO - Refactor 'Cause' to be 'Error' so that native Go error unwrapping works with a slackerror
// useful for api errors
APIEndpoint string
}
A custom Error for the Slack CLI and API errors
func JSONUnmarshalError ¶
JSONUnmarshalError returns a human readable json unmarshal error for CLI users Simply displaying the json.Unmarshal errors have proven to be very confusing already. This attempts to ensure the user understands that the CLI is trying to parse a JSON but is running into some issues.
func New ¶
New returns an Error struct. It first searches our known errors based on the error message to find it. If the error exists it returns the known error struct. Otherwise it creates a new Error and returns that.
func NewAPIError ¶
func NewAPIError(errorCode string, description string, details ErrorDetails, apiEndpoint string) *Error
NewAPIError returns an API error with details and error code
func ToSlackError ¶
ToSlackError will cast an error to our custom Error type
func Wrap ¶
Wrap returns an error and the supplied message. If err is nil, Wrap returns a new error. Wrap returns a new error with message and the cause as err.
func (*Error) AddAPIMethod ¶
AddAPIMethod will set the api endpoint for a slack error It is useful for rendering API errors
func (*Error) AddDetail ¶
func (e *Error) AddDetail(detail ErrorDetail) *Error
AddDetail will add an error detail to a slack error
func (*Error) AppendMessage ¶
AppendMessage will append to the error Message if one exists already If none exists, it will set message as the error Message
func (*Error) AppendRemediation ¶
AppendRemediation will append to the Remediation if one exists already If none exists, it will set remediationMsg as the error's Remidiation
func (*Error) WithDetails ¶
func (e *Error) WithDetails(details ErrorDetails) *Error
WithDetails will set the error details for a slack error
func (*Error) WithMessage ¶
WithMessage will set the error message for a slack error
func (*Error) WithRemediation ¶
WithRemediation will set the remediation text for a slack error
func (*Error) WithRootCause ¶
WithRootCause will add err as part of the error details of this error.
type ErrorDetail ¶
type ErrorDetail struct {
Code string `json:"code,omitempty"`
Constraint constraint `json:"constraint,omitempty"`
Message string `json:"message,omitempty"`
Pointer string `json:"pointer,omitempty"`
Remediation string `json:"remediation,omitempty"`
RelatedComponent string `json:"related_component,omitempty"`
Item map[string]interface{} `json:"item,omitempty"`
}
type ErrorDetails ¶
type ErrorDetails []ErrorDetail