Skip to content
This repository was archived by the owner on Feb 19, 2026. It is now read-only.

Commit 48563ef

Browse files
committed
fix: cannot panic when found unparsable bmson
1 parent 45e2db3 commit 48563ef

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cli/src/bms.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use std::{cell::LazyCell, collections::HashMap, fs::FileType, path::Path};
55

66
use blocking::unblock;
77
use bms_rs::{
8-
bms::{BmsOutput, BmsWarning, parse_bms, prelude::PlayingWarning},
9-
bmson::{Bmson, bmson_to_bms::BmsonToBmsOutput},
10-
parse::model::Bms,
8+
bms::prelude::*,
9+
bmson::bmson_to_bms::BmsonToBmsOutput,
1110
};
1211
use futures::stream::{self, StreamExt as FuturesStreamExt};
1312
use smol::{fs, io};
@@ -73,7 +72,13 @@ async fn read_bmson_file(file: &Path) -> io::Result<Vec<u8>> {
7372

7473
/// 仅负责解析 BMSON 字节(CPU 密集,单线程执行)
7574
fn parse_bmson_bytes(bytes: &[u8]) -> io::Result<BmsOutput> {
76-
let bmson: Bmson = serde_json::from_slice(bytes).map_err(io::Error::other)?;
75+
let Some(bmson) = serde_json::from_slice(bytes).map_err(io::Error::other)? else {
76+
let output = BmsOutput {
77+
bms: Bms::default(),
78+
warnings: vec![BmsWarning::PlayingError(PlayingError::NoNotes)],
79+
};
80+
return Ok(output);
81+
};
7782
let BmsonToBmsOutput {
7883
bms,
7984
warnings: _,

0 commit comments

Comments
 (0)