fix: Create errors-file if it does not exist (#520)
When passed `--errors-file`, the file should not need to already exist on disk to be written into
This commit is contained in:
@ -56,6 +56,16 @@ func (p *writeParams) makeErrorFile() (*os.File, error) {
|
|||||||
if p.ErrorsFile == "" {
|
if p.ErrorsFile == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_, err := os.Stat(p.ErrorsFile)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
file, err := os.Create(p.ErrorsFile)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create errors-file: %w", err)
|
||||||
|
}
|
||||||
|
return file, nil
|
||||||
|
}
|
||||||
|
|
||||||
errorFile, err := os.Open(p.ErrorsFile)
|
errorFile, err := os.Open(p.ErrorsFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to open errors-file: %w", err)
|
return nil, fmt.Errorf("failed to open errors-file: %w", err)
|
||||||
|
Reference in New Issue
Block a user