forked from fclairamb/ftpserverlib
/
errors.go
25 lines (22 loc) · 793 Bytes
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package ftpserver
import "errors"
var (
// ErrStorageExceeded defines the error mapped to the FTP 552 reply code.
// As for RFC 959 this error is checked for STOR, APPE
ErrStorageExceeded = errors.New("storage limit exceeded")
// ErrFileNameNotAllowed defines the error mapped to the FTP 553 reply code.
// As for RFC 959 this error is checked for STOR, APPE, RNTO
ErrFileNameNotAllowed = errors.New("filename not allowed")
// Generate error if abort is called by client to throw error to
ErrAbort = errors.New("abort triggered")
)
func getErrorCode(err error, defaultCode int) int {
switch {
case errors.Is(err, ErrStorageExceeded):
return StatusActionAborted
case errors.Is(err, ErrFileNameNotAllowed):
return StatusActionNotTakenNoFile
default:
return defaultCode
}
}