@@ -49,15 +49,15 @@ fn load_more() -> impl Future<Item = JsValue, Error = JsValue> {
4949
5050fn document ( ) -> web_sys:: Document {
5151 web_sys:: window ( )
52- . expect ( "no window" )
52+ . expect_throw ( "no window" )
5353 . document ( )
54- . expect ( "no document" )
54+ . expect_throw ( "no document" )
5555}
5656
5757fn add_load_more_button ( ) {
5858 let btn = document ( )
5959 . create_element ( "button" )
60- . expect ( "could not create button" ) ;
60+ . expect_throw ( "could not create button" ) ;
6161 btn. set_inner_html ( "I WANT MORE PUPPIES" ) ;
6262 let on_click = Closure :: wrap (
6363 Box :: new ( move || future_to_promise ( load_more ( ) ) ) as Box < FnMut ( ) -> js_sys:: Promise >
@@ -67,12 +67,13 @@ fn add_load_more_button() {
6767 & on_click
6868 . as_ref ( )
6969 . dyn_ref ( )
70- . expect ( "on click is not a Function" ) ,
70+ . expect_throw ( "on click is not a Function" ) ,
7171 )
72- . expect ( "could not add event listener to load more button" ) ;
72+ . expect_throw ( "could not add event listener to load more button" ) ;
7373
74- let doc = document ( ) . body ( ) . expect ( "no body" ) ;
75- doc. append_child ( & btn) . expect ( "could not append button" ) ;
74+ let doc = document ( ) . body ( ) . expect_throw ( "no body" ) ;
75+ doc. append_child ( & btn)
76+ . expect_throw ( "could not append button" ) ;
7677
7778 on_click. forget ( ) ;
7879}
@@ -82,27 +83,27 @@ fn render_response(response: graphql_client_web::Response<puppy_smiles::Response
8283
8384 log ( & format ! ( "response body\n \n {:?}" , response) ) ;
8485
85- let parent = document ( ) . body ( ) . expect ( "no body" ) ;
86+ let parent = document ( ) . body ( ) . expect_throw ( "no body" ) ;
8687
8788 let json: graphql_client_web:: Response < puppy_smiles:: ResponseData > = response;
8889 let response = document ( )
8990 . create_element ( "div" )
90- . expect ( "could not create div" ) ;
91+ . expect_throw ( "could not create div" ) ;
9192 let mut inner_html = String :: new ( ) ;
9293 let listings = json
9394 . data
94- . expect ( "response data" )
95+ . expect_throw ( "response data" )
9596 . reddit
96- . expect ( "reddit" )
97+ . expect_throw ( "reddit" )
9798 . subreddit
98- . expect ( "puppy smiles subreddit" )
99+ . expect_throw ( "puppy smiles subreddit" )
99100 . new_listings ;
100101
101102 let new_cursor: Option < String > = listings[ listings. len ( ) - 1 ]
102103 . as_ref ( )
103104 . map ( |puppy| puppy. fullname_id . clone ( ) )
104105 . to_owned ( ) ;
105- LAST_ENTRY . lock ( ) . unwrap ( ) . replace ( new_cursor) ;
106+ LAST_ENTRY . lock ( ) . unwrap_throw ( ) . replace ( new_cursor) ;
106107
107108 for puppy in & listings {
108109 if let Some ( puppy) = puppy {
@@ -118,7 +119,7 @@ fn render_response(response: graphql_client_web::Response<puppy_smiles::Response
118119 "# ,
119120 puppy. title, puppy. url, puppy. title
120121 )
121- . expect ( "write to string" ) ;
122+ . expect_throw ( "write to string" ) ;
122123 }
123124 }
124125 response. set_inner_html ( & format ! (
@@ -127,20 +128,20 @@ fn render_response(response: graphql_client_web::Response<puppy_smiles::Response
127128 ) ) ;
128129 parent
129130 . append_child ( & response)
130- . expect ( "could not append response" ) ;
131+ . expect_throw ( "could not append response" ) ;
131132}
132133
133134#[ wasm_bindgen( start) ]
134135pub fn run ( ) {
135136 log ( "Hello there" ) ;
136137 let message_area = document ( )
137138 . create_element ( "div" )
138- . expect ( "could not create div" ) ;
139+ . expect_throw ( "could not create div" ) ;
139140 message_area. set_inner_html ( "<p>good morning</p>" ) ;
140- let parent = document ( ) . body ( ) . unwrap ( ) ;
141+ let parent = document ( ) . body ( ) . unwrap_throw ( ) ;
141142 parent
142143 . append_child ( & message_area)
143- . expect ( "could not append message area" ) ;
144+ . expect_throw ( "could not append message area" ) ;
144145
145146 load_more ( ) ;
146147 add_load_more_button ( ) ;
0 commit comments