File tree Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Expand file tree Collapse file tree 3 files changed +15
-27
lines changed Original file line number Diff line number Diff line change @@ -3,36 +3,26 @@ package polycode
33import (
44 "context"
55 "encoding/json"
6+ "errors"
67)
78
89type AppConfig map [string ]interface {}
910
10- func FromAppConfig (ctx context.Context , configObj any ) {
11- srvCtx , ok := ctx .(ServiceContext )
11+ func FromAppConfig (ctx context.Context , configObj any ) error {
12+ baseCtx , ok := ctx .(BaseContext )
1213 if ok {
13- ret := srvCtx .AppConfig ()
14+ ret := baseCtx .AppConfig ()
1415 b , err := json .Marshal (configObj )
1516 if err != nil {
16- panic (err )
17- }
18- err = json .Unmarshal (b , & ret )
19- if err != nil {
20- panic (err )
21- }
22- return
23- }
24- wkfCtx , ok := ctx .(WorkflowContext )
25- if ok {
26- ret := wkfCtx .AppConfig ()
27- b , err := json .Marshal (configObj )
28- if err != nil {
29- panic (err )
17+ return err
3018 }
19+
3120 err = json .Unmarshal (b , & ret )
3221 if err != nil {
33- panic ( err )
22+ return err
3423 }
35- return
24+ return nil
3625 }
37- panic ("invalid context" )
26+
27+ return errors .New ("invalid context" )
3828}
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package polycode
22
33import (
44 "fmt"
5- "log"
65 "os"
76)
87
@@ -21,7 +20,7 @@ func InitClientEnv() {
2120 var appPort uint
2221 _ , err := fmt .Sscanf (appPortStr , "%d" , & appPort )
2322 if err != nil {
24- log . Fatalf ( "invalid APP_PORT: %s" , appPortStr )
23+ appPort = 9998
2524 }
2625
2726 clientEnv = & ClientEnv {
Original file line number Diff line number Diff line change @@ -81,14 +81,13 @@ func loadAppConfig() AppConfig {
8181 log .Println ("client: application.yml not found. generating empty config" )
8282 yamlData = make (map [string ]interface {}) // Create an empty config
8383 } else if err != nil {
84- log .Printf ("client: error reading yml file: %v \n " , err )
85- panic ( err )
84+ log .Printf ("client: error reading yml file. generating empty config : %s \n " , err . Error () )
85+ yamlData = make ( map [ string ] interface {}) // Create an empty config
8686 } else {
87- // Parse the YAML file into a map
8887 err = yaml .Unmarshal (data , & yamlData )
8988 if err != nil {
90- log .Printf ("client: error unmarshalling yml: %v \n " , err )
91- panic ( err )
89+ log .Printf ("client: error unmarshalling yml. generating empty config : %s \n " , err . Error () )
90+ yamlData = make ( map [ string ] interface {} )
9291 }
9392 }
9493
You can’t perform that action at this time.
0 commit comments