Skip to content

Commit

Permalink
add panic to all fatal logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sambukowski committed Apr 2, 2024
1 parent bcce2c4 commit 449c390
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cmd/devtools/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ func recreateCometbftAndSequencerGenesisData(path string) {
genesisData, err := fs.ReadFile(embeddedCometbftGenesisFile, "config/genesis.json")
if err != nil {
log.Fatalf("failed to read embedded file: %v", err)
panic(err)
}
// Read the content from the embedded file
validatorData, err := fs.ReadFile(embeddedCometbftValidatorFile, "config/priv_validator_key.json")
if err != nil {
log.Fatalf("failed to read embedded file: %v", err)
panic(err)
}

// Specify the path for the new file
Expand All @@ -111,22 +113,26 @@ func recreateCometbftAndSequencerGenesisData(path string) {
newGenesisFile, err := os.Create(newGenesisPath)
if err != nil {
log.Fatalf("failed to create new file: %v", err)
panic(err)
}
defer newGenesisFile.Close()
newValidatorFile, err := os.Create(newValidatorPath)
if err != nil {
log.Fatalf("failed to create new file: %v", err)
panic(err)
}
defer newValidatorFile.Close()

// Write the data to the new file
_, err = newGenesisFile.Write(genesisData)
if err != nil {
log.Fatalf("failed to write data to new file: %v", err)
panic(err)
}
_, err = newValidatorFile.Write(validatorData)
if err != nil {
log.Fatalf("failed to write data to new file: %v", err)
panic(err)
}
log.Info("Cometbft genesis data created successfully.")
log.Info("Cometbft validator data created successfully.")
Expand All @@ -141,6 +147,7 @@ func recreateLocalEnvFile(instancDir string, path string) {
data, err := fs.ReadFile(embeddedLocalEnvironmentFile, "config/local.env.example")
if err != nil {
log.Fatalf("failed to read embedded file: %v", err)
panic(err)
}

// Convert data to a string and replace "~" with the user's home directory
Expand All @@ -153,13 +160,15 @@ func recreateLocalEnvFile(instancDir string, path string) {
newFile, err := os.Create(newPath)
if err != nil {
log.Fatalf("failed to create new file: %v", err)
panic(err)
}
defer newFile.Close()

// Write the data to the new file
_, err = newFile.WriteString(content)
if err != nil {
log.Fatalf("failed to write data to new file: %v", err)
panic(err)
}
log.Info("Local .env file created successfully.")
}
Expand All @@ -172,6 +181,7 @@ func recreateRemoteEnvFile(instancDir string, path string) {
data, err := fs.ReadFile(embeddedRemoteEnvironmentFile, "config/remote.env.example")
if err != nil {
log.Fatalf("failed to read embedded file: %v", err)
panic(err)
}

// Specify the path for the new file
Expand All @@ -181,13 +191,15 @@ func recreateRemoteEnvFile(instancDir string, path string) {
newFile, err := os.Create(newPath)
if err != nil {
log.Fatalf("failed to create new file: %v", err)
panic(err)
}
defer newFile.Close()

// Write the data to the new file
_, err = newFile.WriteString(string(data))
if err != nil {
log.Fatalf("failed to write data to new file: %v", err)
panic(err)
}
log.Info("Remote .env file created successfully.")
}
Expand Down Expand Up @@ -290,6 +302,7 @@ func downloadAndUnpack(url string, packageName string, placePath string) {
err = os.Remove(dest)
if err != nil {
log.Fatalf("Failed to delete downloaded %s.tar.gz file: %v", packageName, err)
panic(err)
}
log.Infof("%s downloaded and extracted successfully.\n", packageName)
}
Expand Down

0 comments on commit 449c390

Please sign in to comment.