118118from open_webui .utils .access_control import has_permission
119119from open_webui .utils .access_control .files import has_access_to_file
120120from open_webui .utils .auth import get_admin_user , get_verified_user
121- from open_webui .utils .errors import error_detail
122121from open_webui .utils .misc import (
123122 calculate_sha256_string ,
124123 sanitize_text_for_db ,
@@ -183,7 +182,7 @@ def get_rf(
183182
184183 except Exception as e :
185184 log .error (f'ColBERT: { e } ' )
186- raise Exception (error_detail (e , 'Error loading reranking model' ))
185+ raise Exception (ERROR_MESSAGES . DEFAULT (e , 'Error loading reranking model' ))
187186 else :
188187 if engine == 'external' :
189188 try :
@@ -197,7 +196,9 @@ def get_rf(
197196 )
198197 except Exception as e :
199198 log .error (f'ExternalReranking: { e } ' )
200- raise Exception (error_detail (e , 'Error loading reranking model' ))
199+ raise Exception (
200+ ERROR_MESSAGES .DEFAULT (e , 'Error loading reranking model' )
201+ )
201202 else :
202203 import sentence_transformers
203204 import torch
@@ -217,7 +218,7 @@ def get_rf(
217218 )
218219 except Exception as e :
219220 log .error (f'CrossEncoder: { e } ' )
220- raise Exception (ERROR_MESSAGES .DEFAULT ('CrossEncoder error' ))
221+ raise Exception (ERROR_MESSAGES .DEFAULT (e , 'CrossEncoder error' ))
221222
222223 # Safely adjust pad_token_id if missing as some models do not have this in config
223224 try :
@@ -606,7 +607,7 @@ async def update_embedding_config(request: Request, form_data: EmbeddingModelUpd
606607 log .exception (f'Problem updating embedding model: { e } ' )
607608 raise HTTPException (
608609 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
609- detail = error_detail (e , 'Error updating embedding configuration' ),
610+ detail = ERROR_MESSAGES . DEFAULT (e , 'Error updating embedding configuration' ),
610611 )
611612
612613
@@ -1208,7 +1209,7 @@ async def update_rag_config(request: Request, form_data: ConfigForm, user=Depend
12081209 log .exception (f'Problem updating reranking model: { e } ' )
12091210 raise HTTPException (
12101211 status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
1211- detail = error_detail (e , 'Error updating reranking configuration' ),
1212+ detail = ERROR_MESSAGES . DEFAULT (e , 'Error updating reranking configuration' ),
12121213 )
12131214
12141215 # Chunking settings
@@ -2146,11 +2147,13 @@ async def process_web(
21462147 'status' : True ,
21472148 'content' : content ,
21482149 }
2150+ except HTTPException :
2151+ raise
21492152 except Exception as e :
21502153 log .exception (e )
21512154 raise HTTPException (
21522155 status_code = status .HTTP_400_BAD_REQUEST ,
2153- detail = error_detail (e , 'Error querying knowledge base' ),
2156+ detail = ERROR_MESSAGES . DEFAULT (e , 'Error querying knowledge base' ),
21542157 )
21552158
21562159
@@ -2653,11 +2656,13 @@ async def search_query_with_semaphore(query):
26532656 'filenames' : urls ,
26542657 'loaded_count' : len (docs ),
26552658 }
2659+ except HTTPException :
2660+ raise
26562661 except Exception as e :
26572662 log .exception ('Web search content loading failed' )
26582663 raise HTTPException (
26592664 status .HTTP_400_BAD_REQUEST ,
2660- detail = error_detail (e , ERROR_MESSAGES .WEB_SEARCH_ERROR ()),
2665+ detail = ERROR_MESSAGES . DEFAULT (e , ERROR_MESSAGES .WEB_SEARCH_ERROR ()),
26612666 )
26622667
26632668
@@ -2732,11 +2737,13 @@ async def query_doc_handler(
27322737 k = form_data .k if form_data .k else config .TOP_K ,
27332738 user = user ,
27342739 )
2740+ except HTTPException :
2741+ raise
27352742 except Exception as e :
27362743 log .exception (e )
27372744 raise HTTPException (
27382745 status_code = status .HTTP_400_BAD_REQUEST ,
2739- detail = error_detail (e , 'Error querying knowledge base' ),
2746+ detail = ERROR_MESSAGES . DEFAULT (e , 'Error querying knowledge base' ),
27402747 )
27412748
27422749
@@ -2798,11 +2805,13 @@ async def query_collection_handler(
27982805 k = form_data .k if form_data .k else config .TOP_K ,
27992806 )
28002807
2808+ except HTTPException :
2809+ raise
28012810 except Exception as e :
28022811 log .exception (e )
28032812 raise HTTPException (
28042813 status_code = status .HTTP_400_BAD_REQUEST ,
2805- detail = error_detail (e , 'Error querying knowledge base' ),
2814+ detail = ERROR_MESSAGES . DEFAULT (e , 'Error querying knowledge base' ),
28062815 )
28072816
28082817
0 commit comments