Skip to main content

bge_m3_embedding_server/embedder/
error.rs

1// Copyright (c) 2026 J. Patrick Fulton
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Error helpers for the embedder.
16
17/// Converts an ort error to an anyhow error by formatting it as a string.
18///
19/// `ort::Error` became generic in rc.12 (`ort::Error<T>`) and its variants gained
20/// `NonNull<>` pointer fields that are `!Send + !Sync`, preventing direct
21/// `?`-propagation into `anyhow::Error` (which requires `Send + Sync + 'static`).
22/// Accepting `impl Display` makes this helper work for all instantiations
23/// (`ort::Error<()>`, `ort::Error<SessionBuilder>`, etc.) without naming the type.
24pub(super) fn ort_err(e: impl std::fmt::Display) -> anyhow::Error {
25    anyhow::anyhow!("{e}")
26}