Skip to content

Commit

Permalink
Don't use fmt.Errorf without formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed May 29, 2024
1 parent 578670b commit 9630f9b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dialog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func (f *fileDialog) setLocation(dir fyne.URI) error {
f.files.Unselect(f.selectedID)
}
if dir == nil {
return fmt.Errorf("failed to open nil directory")
return errors.New("failed to open nil directory")
}
list, err := storage.ListerForURI(dir)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions internal/driver/mobile/app/shiny.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

package app

import (
"fmt"
)
import "log"

func main(f func(a App)) {
fmt.Errorf("Running mobile simulation mode does not currently work on Windows.")
log.Fatalln("Running mobile simulation mode does not currently work on Windows.")
}

func GoBack() {
Expand Down
4 changes: 2 additions & 2 deletions internal/driver/mobile/folder.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mobile

import (
"fmt"
"errors"

"fyne.io/fyne/v2"
)
Expand All @@ -16,7 +16,7 @@ func (l *lister) List() ([]fyne.URI, error) {

func listerForURI(uri fyne.URI) (fyne.ListableURI, error) {
if !canListURI(uri) {
return nil, fmt.Errorf("specified URI is not listable")
return nil, errors.New("specified URI is not listable")
}

return &lister{uri}, nil
Expand Down
3 changes: 2 additions & 1 deletion internal/painter/gl/texture.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gl

import (
"errors"
"fmt"
"image"
"image/draw"
Expand Down Expand Up @@ -37,7 +38,7 @@ func (p *painter) getTexture(object fyne.CanvasObject, creator func(canvasObject
cache.SetTexture(object, texture, p.canvas)
}
if !cache.IsValid(texture) {
return noTexture, fmt.Errorf("no texture available")
return noTexture, errors.New("no texture available")
}
return Texture(texture), nil
}
Expand Down
8 changes: 5 additions & 3 deletions test/testfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"fyne.io/fyne/v2/storage"
)

var errUnsupportedURLProtocol = errors.New("unsupported URL protocol")

type file struct {
*os.File
path string
Expand Down Expand Up @@ -45,7 +47,7 @@ func (f *file) URI() fyne.URI {

func openFile(uri fyne.URI, create bool) (*file, error) {
if uri.Scheme() != "file" {
return nil, errors.New("unsupported URL protocol")
return nil, errUnsupportedURLProtocol
}

path := uri.Path()
Expand All @@ -68,7 +70,7 @@ func (d *testDriver) FileWriterForURI(uri fyne.URI) (fyne.URIWriteCloser, error)

func (d *testDriver) ListerForURI(uri fyne.URI) (fyne.ListableURI, error) {
if uri.Scheme() != "file" {
return nil, errors.New("unsupported URL protocol")
return nil, errUnsupportedURLProtocol
}

path := uri.String()[len(uri.Scheme())+3 : len(uri.String())]
Expand All @@ -86,7 +88,7 @@ func (d *testDriver) ListerForURI(uri fyne.URI) (fyne.ListableURI, error) {

func (d *directory) List() ([]fyne.URI, error) {
if d.Scheme() != "file" {
return nil, fmt.Errorf("unsupported URL protocol")
return nil, errUnsupportedURLProtocol
}

path := d.String()[len(d.Scheme())+3 : len(d.String())]
Expand Down

0 comments on commit 9630f9b

Please sign in to comment.