You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Now you might be wondering why another library when there are already a few impl
25
25
* It boasts high speed and efficiency.
26
26
* The implementation achieves 100% test coverage.
27
27
* It follows Pythonic principles, resulting in clean and readable code.
28
-
* It adds some cool innovative features like conditions and an even more declarative look
28
+
* It adds some cool innovative features such as conditions or error handling and an even more declarative look.
29
29
30
30
Let's take a look at a small example:
31
31
@@ -102,6 +102,31 @@ Considering the above characteristics, a stream can be defined as follows:
102
102
103
103
Conditions provide a convenient means for performing logical operations within your Stream, such as using `filter()`, `take_while()`, `drop_while()`, and more. With PyStreamAPI, you have access to a staggering 111 diverse conditions that enable you to process various data types including strings, types, numbers, and dates. Additionally, PyStreamAPI offers a powerful combiner that allows you to effortlessly combine multiple conditions, facilitating the implementation of highly intricate pipelines.
104
104
105
+
## Error handling: Work with data that you don't know
106
+
PyStreamAPI offers a powerful error handling mechanism that allows you to handle errors in a declarative manner. This is especially useful when working with data that you don't know.
107
+
108
+
PyStreamAPI offers three different error levels:
109
+
-`ErrorLevel.RAISE`: This is the default error level. It will raise an exception if an error occurs.
110
+
-`ErrorLevel.IGNORE`: This error level will ignore any errors that occur and won't inform you.
111
+
-`ErrorLevel.WARN`: This error level will warn you about any errors that occur and logs them as a warning with default logger.
112
+
113
+
114
+
This is how you can use them:
115
+
116
+
```python
117
+
from pystreamapi import Stream, ErrorLevel
118
+
119
+
Stream.of(["", '3', None, "2", 1, ""])
120
+
.error_level(ErrorLevel.IGNORE)
121
+
.map_to_int()
122
+
.sorted()
123
+
.for_each(print) # Output: 1 2 3
124
+
```
125
+
126
+
The code above will ignore all errors that occur during mapping to int and will just skip the elements.
127
+
128
+
For more details on how to use error handling, please refer to the documentation.
129
+
105
130
## Get started: Installation
106
131
107
132
To start using PyStreamAPI just install the module with this command:
0 commit comments