generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #499 from Jougan-0/errorHandlingForRegistry
Error handling for registry
- Loading branch information
Showing
3 changed files
with
89 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,43 @@ | ||
package registry | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/layer5io/meshkit/errors" | ||
) | ||
|
||
var ( | ||
ErrUnknownHostCode = "meshkit-11146" | ||
ErrRegisterEntityCode = "meshkit-11244" | ||
|
||
ErrUnknownHostCode = "replace_me" | ||
ErrEmptySchemaCode = "replace_me" | ||
ErrMarshalingRegisteryAttemptsCode = "replace_me" | ||
ErrWritingRegisteryAttemptsCode = "replace_me" | ||
ErrRegisteringEntityCode = "replace_me" | ||
ErrUnknownHostInMapCode = "replace_me" | ||
ErrCreatingUserDataDirectoryCode = "replace_me" | ||
|
||
) | ||
|
||
func ErrUnknownHost(err error) error { | ||
return errors.New(ErrUnknownHostCode, errors.Alert, []string{"host is not supported"}, []string{err.Error()}, []string{"The component's host is not supported by the version of server you are running"}, []string{"Try upgrading to latest available version"}) | ||
} | ||
func ErrUnknownHostInMap() error { | ||
return errors.New( | ||
ErrUnknownHostInMapCode, errors.Alert, []string{"Host not found in registry logs."}, nil, []string{"The specified host does not have any associated registry logs or is unrecognized.", "Ensure the host name is correct and exists in the registry logs.", "Refer to .meshery/logs/registryLogs.txt for more details."}, []string{"Verify the host name used during the registration process.", "Check the registry logs file for potential errors and additional information."}) | ||
} | ||
|
||
func ErrEmptySchema() error { | ||
return errors.New(ErrEmptySchemaCode, errors.Alert, []string{"Empty schema for the component"}, []string{"Empty schema for the component"}, []string{"The schema is empty for the component."}, []string{"For the particular component the schema is empty. Use the docs or discussion forum for more details "}) | ||
} | ||
func ErrMarshalingRegisteryAttempts(err error) error { | ||
return errors.New(ErrMarshalingRegisteryAttemptsCode, errors.Alert, []string{"Error marshaling RegisterAttempts to JSON"}, []string{"Error marshaling RegisterAttempts to JSON: ", err.Error()}, []string{}, []string{}) | ||
} | ||
func ErrWritingRegisteryAttempts(err error) error { | ||
return errors.New(ErrWritingRegisteryAttemptsCode, errors.Alert, []string{"Error writing RegisteryAttempts JSON data to file"}, []string{"Error writing RegisteryAttempts JSON data to file:", err.Error()}, []string{}, []string{}) | ||
} | ||
func ErrRegisteringEntity(failedMsg string, hostName string) error { | ||
return errors.New(ErrRegisteringEntityCode, errors.Alert, []string{fmt.Sprintf("The import process for a registrant %s encountered difficulties,due to which %s. Specific issues during the import process resulted in certain entities not being successfully registered in the table.", hostName, failedMsg)}, []string{fmt.Sprintf("For registrant %s %s", hostName, failedMsg)}, []string{"Could be because of empty schema or some issue with the json or yaml file"}, []string{"Check /server/cmd/registery_attempts.json for futher details"}) | ||
} | ||
func ErrCreatingUserDataDirectory(dir string) error { | ||
return errors.New(ErrCreatingUserDataDirectoryCode, errors.Fatal, []string{"Unable to create the directory for storing user data at: ", dir}, []string{"Unable to create the directory for storing user data at: ", dir}, []string{}, []string{}) | ||
} |
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