Commit 04590cb
feat(python-sdk): introduce LangfuseAuthException for auth_check failures
Bare Exception raises are bad practice in Python because they cannot be
cleanly caught without also masking unrelated bugs (ImportError, NameError,
SyntaxError, etc.).
This commit introduces LangfuseAuthException(Exception), a dedicated
exception class for authentication failures, and replaces the bare
raise Exception(...) in Langfuse.auth_check() with it.
Users can now guard specifically against auth failures:
from langfuse import Langfuse, LangfuseAuthException
try:
Langfuse().auth_check()
except LangfuseAuthException as e:
logger.warning('Langfuse auth failed: %s', e)
LangfuseAuthException is exported from the top-level langfuse package.
Closes langfuse/langfuse#906
Co-authored-by: nik464 <nik464@users.noreply.github.com>1 parent 8bcc8fa commit 04590cb
3 files changed
Lines changed: 27 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
3166 | 3167 | | |
3167 | 3168 | | |
3168 | 3169 | | |
3169 | | - | |
| 3170 | + | |
3170 | 3171 | | |
3171 | 3172 | | |
3172 | 3173 | | |
| |||
3177 | 3178 | | |
3178 | 3179 | | |
3179 | 3180 | | |
3180 | | - | |
| 3181 | + | |
3181 | 3182 | | |
3182 | 3183 | | |
3183 | 3184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
0 commit comments