Commit 6412c75
authored
fix: Improve error handling in task creation (#294)
# Description
This update improves the robustness of the `new_task` function by adding
explicit error handling for invalid `Message` objects.
Previously, `new_task` did not validate its input, which could lead to
unexpected `TypeError` or `ValueError` exceptions when a malformed
`Message` was passed. This change introduces checks to ensure that a
`Message` has a valid `role` and a non-empty `parts` list before a
`Task` is created.
Additionally, this update includes corresponding unit tests to verify
the new error handling and ensures that the correct exceptions are
raised for invalid inputs.1 parent e781ced commit 6412c75
2 files changed
+28
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
116 | 135 | | |
117 | 136 | | |
118 | 137 | | |
0 commit comments