diff options
Diffstat (limited to 'examples/7-rdfloader/exampleRDFLoader.go')
-rw-r--r-- | examples/7-rdfloader/exampleRDFLoader.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/examples/7-rdfloader/exampleRDFLoader.go b/examples/7-rdfloader/exampleRDFLoader.go index e2fe624..08dc1ba 100644 --- a/examples/7-rdfloader/exampleRDFLoader.go +++ b/examples/7-rdfloader/exampleRDFLoader.go @@ -1,5 +1,5 @@ // SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later - +// Run project: go run exampleRDFLoader.go ../sample-docs/rdf/SPDXRdfExample-v2.2.spdx.rdf package main import ( @@ -9,20 +9,25 @@ import ( "strings" ) -func getFilePathFromUser() string { +func getFilePathFromUser() (string, error) { if len(os.Args) == 1 { // user hasn't specified the rdf file path - panic("kindly provide path of the rdf file to be loaded as a spdx-document while running this file") + return "", fmt.Errorf("kindly provide path of the rdf file to be loaded as a spdx-document while running this file") } - return os.Args[1] + return os.Args[1], nil } func main() { // example to use the rdfLoader. - filePath := getFilePathFromUser() + filePath, ok := getFilePathFromUser() + if ok != nil { + fmt.Println(fmt.Errorf("%v", ok)) + os.Exit(1) + } file, err := os.Open(filePath) if err != nil { - panic(fmt.Errorf("error opening File: %s", err)) + fmt.Println(fmt.Errorf("error opening File: %s", err)) + os.Exit(1) } // loading the spdx-document |