mirror of
https://github.com/genuinetools/reg.git
synced 2024-05-13 09:48:33 -04:00
list: gracefully fail in case of invalid registry (#158)
If the given domain is not a valid registry and try to get the repository list, it fails in unmarshalling and show the JSON syntax error. This will catch the error and show a better error message. Fixes: #157
This commit is contained in:
parent
23cd8e4025
commit
d6e3a0aa00
4
list.go
4
list.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
@ -36,6 +37,9 @@ func (cmd *listCommand) Run(ctx context.Context, args []string) error {
|
|||
// Get the repositories via catalog.
|
||||
repos, err := r.Catalog("")
|
||||
if err != nil {
|
||||
if _, ok := err.(*json.SyntaxError); ok {
|
||||
return fmt.Errorf("Domain %s is not a valid registry", r.Domain)
|
||||
}
|
||||
return err
|
||||
}
|
||||
sort.Strings(repos)
|
||||
|
|
Loading…
Reference in a new issue