// Package crypterrors defines errors that can be returned from crypt.Crypter // implementations.
package crypterrors import ( ) // MalformedHashError is an error that is returned if the crypt.Crypter // implementation receives a malformed PHC formatted string. type MalformedHashError struct { // Hash is the malformed PHC formatted hash string. Hash string } // Error implements the error interface. func ( *MalformedHashError) () string { const = "malformed hash" if == nil { return } return fmt.Sprintf(+" %q", .Hash) } // UnsupportedHashError is an error that is returned if the crypt.Crypter // implementation does not support the requested hash function. type UnsupportedHashError struct { // HashID is the ID of the unsupported hash function. HashID string } // Error implements the error interface. func ( *UnsupportedHashError) () string { const = "unsupported hash" if == nil { return } return fmt.Sprintf(+" %q", .HashID) } // UnsupportedVersionError is an error that is returned if the crypt.Crypter // implementation does not support the requested hash function version. type UnsupportedVersionError struct { // Parsed is the parsed unsupported version. Parsed uint // Suggested is the suggested supported version. Suggested uint } // Error implements the error interface. func ( *UnsupportedVersionError) () string { const = "unsupported version" if == nil { return } return fmt.Sprintf(+" %d (suggested version is %d)", .Parsed, .Suggested) } // UnsupportedParameterError is an error that is returned if the crypt.Crypter // implementation does not support the given parameter for a hash function. type UnsupportedParameterError struct { // Name is the name of the parameter. Name string // Unimplemented indicates that the parameter is defined but not // implemented. Unimplemented bool } // Error implements the error interface. func ( *UnsupportedParameterError) () string { const = "unsupported parameter" if == nil { return } var string if .Unimplemented { = " (not implemented)" } return fmt.Sprintf(+" %q%s", .Name, ) } // InvalidParameterValueError is an error that is returned if the crypt.Crypter // implementation receives an invalid hash function parameter value. type InvalidParameterValueError struct { // Name is the name of the parameter. Name string // Value is the value of the parameter. Value string // Expected is a free-form expected format of the value. Expected string } // Error implements the error interface. func ( *InvalidParameterValueError) () string { const = "invalid value for parameter" if == nil { return } return fmt.Sprintf(+" %q (given %q, expected %s)", .Name, .Value, .Expected) } // MalformedParametersError is an error that is returned if the crypt.Crypter // implementation receives a malformed hash function parameters. type MalformedParametersError struct { // Unparsed is the unparsed parameters string. Unparsed string } // Error implements the error interface. func ( *MalformedParametersError) () string { const = "malformed parameters" if == nil { return } return fmt.Sprintf(+" (unparsed %q)", .Unparsed) } // MissingRequiredParametersError is an error that is returned if the // crypt.Crypter implementation does not receive one of the required hash // function parameters. type MissingRequiredParametersError struct { // Required is the free-form description of the required parameters. Required string } // Error implements the error interface. func ( *MissingRequiredParametersError) () string { const = "missing required parameters" if == nil { return } return fmt.Sprintf(+" (need %s)", .Required) } // InvalidOutputLengthError is an error that is returned if the crypt.Crypter // implementation receives a hash output with invalid length for the password // hashing algorithm. type InvalidOutputLengthError struct { // Length is the given function output length. Length int // Expected is the free-form description of the expected length. Expected string } // Error implements the error interface. func ( *InvalidOutputLengthError) () string { const = "invalid output length" if == nil { return } return fmt.Sprintf(+" %d (expected %s)", .Length, .Expected) }