mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-18 05:02:15 +01:00
handling case no file to convert
This commit is contained in:
@@ -19,6 +19,14 @@ type Converter struct {
|
||||
workingDir string
|
||||
}
|
||||
|
||||
type noFileToConvertError struct{}
|
||||
|
||||
const noFileToConvertErrorMessage = "No file to convert"
|
||||
|
||||
func (e *noFileToConvertError) Error() string {
|
||||
return noFileToConvertErrorMessage
|
||||
}
|
||||
|
||||
// NewConverter instantiates a converter by parsing a request.
|
||||
func NewConverter(r *http.Request) (*Converter, error) {
|
||||
c := &Converter{
|
||||
@@ -53,6 +61,10 @@ func NewConverter(r *http.Request) (*Converter, error) {
|
||||
c.files = append(c.files, f)
|
||||
}
|
||||
|
||||
if len(c.files) == 0 {
|
||||
return c, &noFileToConvertError{}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user