Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ class Unreachable {
message string
}

/// A cancellation was requested.
class Cancelled {
message string
}

/// A user-caused panic from `baml.sys.panic`.
class UserPanic {
message string
Expand All @@ -35,4 +40,4 @@ class AllocFailure {
message string
}

type Panic = DivisionByZero | IndexOutOfBounds | MapKeyNotFound | StackOverflow | AssertionFailed | Unreachable | UserPanic | AllocFailure
type Panic = DivisionByZero | IndexOutOfBounds | MapKeyNotFound | StackOverflow | AssertionFailed | Unreachable | Cancelled | UserPanic | AllocFailure
3 changes: 3 additions & 0 deletions baml_language/crates/baml_builtins2_codegen/src/codegen_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1880,6 +1880,9 @@ pub fn generate_io_adapter(
let resolve_fn = emit_resolve_helper();

let tokens = quote! {
// Bring `HeapPermit::proof()` into scope for the adapter impl below.
use ::bex_heap::HeapPermit as _;

#resolve_fn
#adapter_struct
#adapter_impl
Expand Down
8 changes: 3 additions & 5 deletions baml_language/crates/baml_lsp_server/src/playground_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use axum::{
routing::get,
};
use base64::Engine as _;
use bex_project::{is_cancelled_engine_error, is_cancelled_runtime_error};
use futures::{SinkExt, stream::StreamExt};
use prost::Message;
use tokio::{net::TcpListener, sync::broadcast};
Expand Down Expand Up @@ -294,10 +295,7 @@ async fn handle_ws_in_message(
}
}
Err(e) => {
let is_cancelled = matches!(
&e,
bex_project::RuntimeError::Engine(bex_project::EngineError::Cancelled)
);
let is_cancelled = is_cancelled_runtime_error(&e);
WsOutMessage::CallFunctionError {
id,
error: format!("{e}"),
Expand Down Expand Up @@ -355,7 +353,7 @@ async fn handle_ws_in_message(
}
}
Err(e) => {
let is_cancelled = matches!(&e, bex_project::EngineError::Cancelled);
let is_cancelled = is_cancelled_engine_error(&e);
WsOutMessage::CallFunctionError {
id,
error: format!("{e}"),
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions baml_language/crates/baml_tests/tests/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3013,7 +3013,7 @@ async fn panic_alias_catches_any_panic() {
}
"#
);
insta::assert_snapshot!(output.bytecode, @r"
insta::assert_snapshot!(output.bytecode, @"
function divides() -> int {
load_const 1
load_const 0
Expand All @@ -3026,7 +3026,7 @@ async fn panic_alias_catches_any_panic() {
jump L2
load_var e
type_tag
jump_table [L1, L1, L1, _, _, L1, _, _, _, L1, L1, _, L1, L1], default L0
jump_table [L1, L1, L1, L1, _, _, L1, _, _, _, L1, L1, _, L1, L1], default L0

L0:
load_var e
Expand Down Expand Up @@ -3067,7 +3067,7 @@ async fn panic_alias_plus_wildcard_dispatch() {
jump L2
load_var e
type_tag
jump_table [L1, L1, L1, _, _, L1, _, _, _, L1, L1, _, L1, L1], default L0
jump_table [L1, L1, L1, L1, _, _, L1, _, _, _, L1, L1, _, L1, L1], default L0

L0:
load_var e
Expand Down
Loading
Loading