mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Added actual error message to recover error output
This commit is contained in:
parent
b1945d672d
commit
4d538dfc0c
1 changed files with 10 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/ByteDream/crunchyroll-go"
|
||||
"github.com/spf13/cobra"
|
||||
"net/http"
|
||||
|
|
@ -21,6 +22,10 @@ var (
|
|||
var rootCmd = &cobra.Command{
|
||||
Use: "crunchyroll",
|
||||
Short: "Download crunchyroll videos with ease",
|
||||
|
||||
SilenceErrors: true,
|
||||
SilenceUsage: true,
|
||||
|
||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||
if verboseFlag {
|
||||
out = newLogger(true, true, true)
|
||||
|
|
@ -46,14 +51,17 @@ func Execute() {
|
|||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
if out.IsDev() {
|
||||
out.Err(string(debug.Stack()))
|
||||
out.Err("%v: %s", r, debug.Stack())
|
||||
} else {
|
||||
out.Err("Unexpected error: %v", r)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
if rootCmd.Execute() != nil {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
if err != context.Canceled {
|
||||
out.Exit("An error occurred: %v", err)
|
||||
}
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue