Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorMessage ¶
ErrorMessage unwraps an application error and returns its message. Non-application errors always return "Internal error".
func FindString ¶
FindString returns the search index of sorted strings.
func HasPrefixes ¶
HasPrefixes returns true if the string s has any of the given prefixes.
func RandomString ¶
RandomString returns a random string with length n.
Types ¶
type Code ¶
type Code int
Code is the error code.
const ( // 0 ~ 99 general error Ok Code = 0 Internal Code = 1 NotAuthorized Code = 2 Invalid Code = 3 NotFound Code = 4 Conflict Code = 5 NotImplemented Code = 6 // 101 ~ 199 db error DbConnectionFailure Code = 101 DbStatementSyntaxError Code = 102 DbExecutionError Code = 103 // 201 db migration error // Db migration is a core feature, so we separate it from the db error MigrationSchemaMissing Code = 201 MigrationAlreadyApplied Code = 202 MigrationOutOfOrder Code = 203 MigrationBaselineMissing Code = 204 // 301 task error TaskTimingNotAllowed Code = 301 // 10001 advisor error code CompatibilityDropDatabase Code = 10001 CompatibilityRenameTable Code = 10002 CompatibilityDropTable Code = 10003 CompatibilityRenameColumn Code = 10004 CompatibilityDropColumn Code = 10005 CompatibilityAddPrimaryKey Code = 10006 CompatibilityAddUniqueKey Code = 10007 CompatibilityAddForeignKey Code = 10008 CompatibilityAddCheck Code = 10009 CompatibilityAlterCheck Code = 10010 CompatibilityAlterColumn Code = 10011 )
Application error codes.
type Error ¶
Error represents an application-specific error. Application errors can be unwrapped by the caller to extract out the code & message.
Any non-application error (such as a disk error) should be reported as an Internal error and the human user should only see "Internal error" as the message. These low-level internal error details should only be logged and reported to the operator of the application (not the end user).
type OauthContext ¶
type OauthContext struct { ClientID string ClientSecret string AccessToken string RefreshToken string Refresher TokenRefresher }
OauthContext encapsulated the oauth info
type ProjectRole ¶
type ProjectRole string
ProjectRole is the role in projects.
const ( // ProjectOwner is the owner of a project. ProjectOwner ProjectRole = "OWNER" // ProjectDeveloper is the developer of a project. ProjectDeveloper ProjectRole = "DEVELOPER" )
func (ProjectRole) String ¶
func (e ProjectRole) String() string
type TokenRefresher ¶
TokenRefresher is a function refreshes the oauth token and updates the repository.