File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -15,20 +15,28 @@ pub fn compress(buf: Box<[u8]>) -> Result<Box<[u8]>, JsValue> {
15
15
set_panic_hook ( ) ;
16
16
let mut out = Vec :: < u8 > :: new ( ) ;
17
17
let params = brotli:: enc:: BrotliEncoderParams :: default ( ) ;
18
+
18
19
match brotli:: BrotliCompress ( & mut buf. as_ref ( ) , & mut out, & params) {
19
20
Ok ( _) => ( ) ,
20
- Err ( _) => return Err ( JsValue :: from_str ( "brotli dec failed" ) ) ,
21
+ Err ( e) => return Err ( JsValue :: from_str ( & format ! (
22
+ "Brotli compress failed: {:?}" , e
23
+ ) ) ) ,
21
24
}
25
+
22
26
Ok ( out. into_boxed_slice ( ) )
23
27
}
24
28
25
29
#[ wasm_bindgen( js_name = decompress) ]
26
30
pub fn decompress ( buf : Box < [ u8 ] > ) -> Result < Box < [ u8 ] > , JsValue > {
27
31
set_panic_hook ( ) ;
28
32
let mut out = Vec :: < u8 > :: new ( ) ;
33
+
29
34
match brotli:: BrotliDecompress ( & mut buf. as_ref ( ) , & mut out) {
30
35
Ok ( _) => ( ) ,
31
- Err ( _) => return Err ( JsValue :: from_str ( "brotli dec failed" ) ) ,
36
+ Err ( e) => return Err ( JsValue :: from_str ( & format ! (
37
+ "Brotli decompress failed: {:?}" , e
38
+ ) ) ) ,
32
39
}
40
+
33
41
Ok ( out. into_boxed_slice ( ) )
34
42
}
You can’t perform that action at this time.
0 commit comments