giorgio-caparvi commited on
Commit
bcbc057
·
1 Parent(s): 5b474cb

added traceback response

Browse files
Files changed (1) hide show
  1. api/app.py +9 -5
api/app.py CHANGED
@@ -7,6 +7,7 @@ from model.src.utils.arg_parser import eval_parse_args # Nuovo import corretto
7
  import sys
8
  from PIL import Image
9
  import base64
 
10
 
11
 
12
  from model.src import eval
@@ -65,25 +66,28 @@ def generate_design():
65
  ]
66
  print("### Esecuzione eval.main ###") # Stampa per il debug
67
 
 
 
68
  # Esecuzione del modello
69
  try:
70
  final_image = eval.main(img_sketch_buffer, json_data_from_req)
71
  print("### eval.main eseguito con successo ###") # Stampa per il debug
72
  except AttributeError as e:
73
  print(f"### AttributeError: {str(e)} ###") # Stampa per il debug
74
- return f"AttributeError: {str(e)}", 500
75
  except TypeError as e:
76
  print(f"### TypeError: {str(e)} ###") # Stampa per il debug
77
- return f"TypeError: {str(e)}", 500
78
  except ValueError as e:
79
  print(f"### ValueError: {str(e)} ###") # Stampa per il debug
80
- return f"ValueError: {str(e)}", 500
81
  except IOError as e:
82
  print(f"### IOError: {str(e)} ###") # Stampa per il debug
83
- return f"IOError: {str(e)}", 500
84
  except Exception as e:
85
  print(f"### Unexpected error: {str(e)} ###") # Stampa per il debug
86
- return f"Unexpected error: {str(e)}", 500
 
87
 
88
  # Salvataggio immagine e invio come risposta
89
  img_io = io.BytesIO()
 
7
  import sys
8
  from PIL import Image
9
  import base64
10
+ import traceback
11
 
12
 
13
  from model.src import eval
 
66
  ]
67
  print("### Esecuzione eval.main ###") # Stampa per il debug
68
 
69
+ import traceback
70
+
71
  # Esecuzione del modello
72
  try:
73
  final_image = eval.main(img_sketch_buffer, json_data_from_req)
74
  print("### eval.main eseguito con successo ###") # Stampa per il debug
75
  except AttributeError as e:
76
  print(f"### AttributeError: {str(e)} ###") # Stampa per il debug
77
+ return f"AttributeError: {traceback.format_exc()}", 500
78
  except TypeError as e:
79
  print(f"### TypeError: {str(e)} ###") # Stampa per il debug
80
+ return f"TypeError: {traceback.format_exc()}", 500
81
  except ValueError as e:
82
  print(f"### ValueError: {str(e)} ###") # Stampa per il debug
83
+ return f"ValueError: {traceback.format_exc()}", 500
84
  except IOError as e:
85
  print(f"### IOError: {str(e)} ###") # Stampa per il debug
86
+ return f"IOError: {traceback.format_exc()}", 500
87
  except Exception as e:
88
  print(f"### Unexpected error: {str(e)} ###") # Stampa per il debug
89
+ return f"Unexpected error: {traceback.format_exc()}", 500
90
+
91
 
92
  # Salvataggio immagine e invio come risposta
93
  img_io = io.BytesIO()