@@ -253,8 +253,14 @@ impl Context {
253
253
let ( extensions, supported_extensions) = build_extensions ! ( context, WebGlRenderingContext ) ;
254
254
255
255
// Retrieve and parse `GL_VERSION`
256
- let raw_string = context. get_parameter ( VERSION ) . unwrap ( ) . as_string ( ) . unwrap ( ) ;
257
- let version = Version :: parse ( & raw_string) . unwrap ( ) ;
256
+ let raw_jsvalue = context
257
+ . get_parameter ( VERSION )
258
+ . expect ( "context.get_parameter(VERSION) shouldn't throw" ) ;
259
+ let raw_string = raw_jsvalue
260
+ . as_string ( )
261
+ . unwrap_or_else ( || panic ! ( "{:?} should be a string" , raw_jsvalue) ) ;
262
+ let version = Version :: parse ( & raw_string)
263
+ . expect ( "context.get_parameter(VERSION) should be parseable as an OpenGL version" ) ;
258
264
259
265
Self {
260
266
raw : RawRenderingContext :: WebGl1 ( context) ,
@@ -279,8 +285,14 @@ impl Context {
279
285
let ( extensions, supported_extensions) = build_extensions ! ( context, WebGl2RenderingContext ) ;
280
286
281
287
// Retrieve and parse `GL_VERSION`
282
- let raw_string = context. get_parameter ( VERSION ) . unwrap ( ) . as_string ( ) . unwrap ( ) ;
283
- let version = Version :: parse ( & raw_string) . unwrap ( ) ;
288
+ let raw_jsvalue = context
289
+ . get_parameter ( VERSION )
290
+ . expect ( "context.get_parameter(VERSION) shouldn't throw" ) ;
291
+ let raw_string = raw_jsvalue
292
+ . as_string ( )
293
+ . unwrap_or_else ( || panic ! ( "{:?} should be a string" , raw_jsvalue) ) ;
294
+ let version = Version :: parse ( & raw_string)
295
+ . expect ( "context.get_parameter(VERSION) should be parseable as an OpenGL version" ) ;
284
296
285
297
Self {
286
298
raw : RawRenderingContext :: WebGl2 ( context) ,
0 commit comments