Open utterances-bot opened 3 years ago
Hi Aaron,
I am new to Python. I am trying to use your Result class....and returning Result.ok()
in app.py I have like this
def insert_items(): return insert_newstreet("1", "AbC")
in insert_newstreet class i am returning Result.ok()
I am getting an error saying String,Tuple or object is expected but Result is being returned.
Can you help me with this?
Thanks for the idea. I was looking for a way to gracefully handle success/failure situations. This fit the bill perfectly!
Error Handling in Python: Result Class - aaronluna.dev
In a previous post, I explained how concepts from functional programming can be incorporated with object-oriented code to improve the tedious and mandatory task of error handling and input validation through the use of the Result class. That post explained how to implement the Result class in C#. Since I have been writing mostly Python code lately, I created a new implementation and documented its use. Due to Python’s duck-typing, this implementation is (IMO) more natural and makes reasoning about the code it supports much easier.
https://aaronluna.dev/blog/error-handling-python-result-class/