mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 04:02: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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"github.com/ByteDream/crunchyroll-go"
|
"github.com/ByteDream/crunchyroll-go"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
@ -21,6 +22,10 @@ var (
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
Use: "crunchyroll",
|
Use: "crunchyroll",
|
||||||
Short: "Download crunchyroll videos with ease",
|
Short: "Download crunchyroll videos with ease",
|
||||||
|
|
||||||
|
SilenceErrors: true,
|
||||||
|
SilenceUsage: true,
|
||||||
|
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) (err error) {
|
||||||
if verboseFlag {
|
if verboseFlag {
|
||||||
out = newLogger(true, true, true)
|
out = newLogger(true, true, true)
|
||||||
|
|
@ -46,14 +51,17 @@ func Execute() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
if out.IsDev() {
|
if out.IsDev() {
|
||||||
out.Err(string(debug.Stack()))
|
out.Err("%v: %s", r, debug.Stack())
|
||||||
} else {
|
} else {
|
||||||
out.Err("Unexpected error: %v", r)
|
out.Err("Unexpected error: %v", r)
|
||||||
}
|
}
|
||||||
os.Exit(1)
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue