@@ -25,7 +25,7 @@ func main() {
2525 if ! isStringNumber (http_status_code ) {
2626 fmt .Println (
2727 "You must provide a HTTP status code! " +
28- "E.g. http-cat 404, http-cat 500. Run 'http-cat --help' for more help ." ,
28+ "( E.g. http-cat 404, http-cat 500) \n Run 'http-cat --help' for more information ." ,
2929 )
3030 return nil
3131 }
@@ -38,6 +38,16 @@ func main() {
3838 log .Fatalln ("GET request to HTTP Cat API failed:" , err )
3939 }
4040
41+ if response .StatusCode >= 400 {
42+ if response .StatusCode == 404 {
43+ log .Fatalln (
44+ "A 🐈 kitty corresponding to that HTTP status isn't available! Error:" , response .Status ,
45+ )
46+ }
47+
48+ log .Fatalln ("API Error:" , response .Status )
49+ }
50+
4151 var temp_directory_path string = getTempDir ()
4252
4353 if _ , err := os .Stat (temp_directory_path ); os .IsNotExist (err ) {
@@ -57,7 +67,9 @@ func main() {
5767 log .Fatalln ("Failed to write the 🐈 kitty in the temp directory:" , err )
5868 }
5969
60- output , err := exec .Command ("chafa" , path_to_image , "--scale" , "0.7" ).Output ()
70+ output , err := exec .Command (
71+ "chafa" , path_to_image , "--scale" , "0.7" ,
72+ ).Output ()
6173
6274 if err != nil {
6375 log .Fatalln (
0 commit comments