pyflowchart icon indicating copy to clipboard operation
pyflowchart copied to clipboard

Try and Execption Doesn't support

Open nikhiltree opened this issue 3 years ago • 9 comments

can you please upgrade this library for a try and exception? Screenshot from 2022-08-04 15-58-31

nikhiltree avatar Aug 04 '22 10:08 nikhiltree

And how would you express try-except statements in a flowchart? AFAIK, I’m afraid that there’s not a standard or well-known pattern for errors handling in flowcharts. So show me a example or I will keep this open until someone can figure it out.

cdfmlr avatar Aug 04 '22 14:08 cdfmlr

x=0
try:
  print(x)
except:
  print("An exception occurred")

Diagram Code : op2=>operation: try: print(x) except: print('An exception occurred')

Actual Graph Screenshot from 2022-08-05 10-50-31

nikhiltree avatar Aug 05 '22 05:08 nikhiltree

it's simple example of try and exception in python

nikhiltree avatar Aug 05 '22 05:08 nikhiltree

@nikhiltree

Diagram Code : op2=>operation: try: print(x) except: print('An exception occurred')

Actual Graph Screenshot from 2022-08-05 10-50-31

I guess it’s the current running result. And by

And how would you express try-except statements in a flowchart? AFAIK, I’m afraid that there’s not a standard or well-known pattern for errors handling in flowcharts. So show me a example or I will keep this open until someone can figure it out.

I mean what’s your expected diagram (a correction) for it?

cdfmlr avatar Aug 05 '22 05:08 cdfmlr

image you can show a flow diagram like the above picture(consider try and except like if and else statements)

nikhiltree avatar Aug 05 '22 11:08 nikhiltree

say, an example:

foo = get_foo()
try:
    c = foo.read()
    print(c)
except:
    print("failed")
foo.close()

to express it in a flowchart, my options are:

  1. as your illustration, missing start of try:
1_missing_strat
  1. not clear for the transferring point (this looks pretty good, but I disapprove of it because I think it's misleading, for the fact that a program will not jump to the except scope from a "try" line):
2_try_line_to_except
  1. to express what a try-except do clearly, I have to make it complex:
3_complex

And we are not even considering the multi-excepts cases which will make things increasingly complex.

cdfmlr avatar Aug 05 '22 13:08 cdfmlr

Thanks, @cdfmlr for your explanation please let me know if you will update this library for solving this type of problem in the future. I am very glad to use this library.

nikhiltree avatar Aug 08 '22 05:08 nikhiltree

Thanks, I will do further research on it later, maybe later this month. And I guess a refactor is required to implement this feature (the early design of this lib is horrible 🤦‍♂️) which should take a bit of time.

cdfmlr avatar Aug 09 '22 10:08 cdfmlr

You are doing great @cdfmlr.

nikhiltree avatar Aug 09 '22 11:08 nikhiltree