-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Fix] Patch minor #22
base: main
Are you sure you want to change the base?
Conversation
// 3. log-level from configuration object. | ||
// 4. given log level from the input. | ||
logLevel := configLogLevel | ||
logLevelViper := a.Viper.GetString("log-level") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we choose to send viper in instead of handling value from cmd?
|
||
// check if file doesn't exist, exit the function as the config may not be initialized. | ||
if _, err := os.Stat(cfgPath); os.IsNotExist(err) { | ||
return nil | ||
} else if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a bit weird to return no-error if the config file doesn't exist? caller will need to check from the variable only to see if it can load successfully.
@@ -211,13 +221,17 @@ func (a *App) InitConfigFile(homePath string, customFilePath string) error { | |||
if err = os.Mkdir(homePath, os.ModePerm); err != nil { | |||
return err | |||
} | |||
} else if err != nil { | |||
return err | |||
} | |||
|
|||
// Create the config folder if doesn't exist | |||
if _, err := os.Stat(cfgDir); os.IsNotExist(err) { | |||
if err = os.Mkdir(cfgDir, os.ModePerm); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be err := instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, maybe we can create helper function to create folder if it doesn't exist.
if len(tunnels) == 0 { | ||
a.Log.Error("No tunnel ID provided") | ||
return fmt.Errorf("no tunnel ID provided") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it also can happen when run with just start
command but there's no tunnel on chain?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for that case, we should not return error.
@@ -99,7 +98,7 @@ func (c *client) Connect(timeout uint) error { | |||
return nil | |||
} | |||
|
|||
return nil | |||
return fmt.Errorf("failed to connect to Band Chain") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BandChain
// Return if there are no RPC endpoints | ||
if len(c.RpcEndpoints) == 0 { | ||
return nil | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why choose to return nil? no endpoints mean can't connect?
Fixed:
Implementation details
Please ensure the following requirements are met before submitting a pull request:
CHANGELOG_UNRELEASED.md
Files changed
tab in the Github PR explorer)