@@ -7,17 +7,29 @@ const URI = 'https://api.douban.com/v2/movie'
77router . prefix ( '/douban' ) 
88
99router . get ( '/:type' ,  async  ctx  =>  { 
10-  let  url  =  ctx . url . replace ( / \/ d o u b a n ( \w * ) / ,  URI  +  '1ドル' ) 
11-  console . log ( ':::' ,  url ,  ':::' ) 
12-  let  result  =  await  request ( { uri : url ,  method : ctx . method } ) 
13-  ctx . body  =  result . body 
10+  let  result 
11+  try  { 
12+  let  url  =  ctx . url . replace ( / \/ d o u b a n ( \w * ) / ,  URI  +  '1ドル' ) 
13+  console . log ( ':::' ,  url ,  ':::' ) 
14+  result  =  await  request ( { uri : url ,  method : ctx . method } ) 
15+  }  catch  ( error )  { 
16+  throw  new  Error ( error ) 
17+  }  finally  { 
18+  ctx . body  =  result . body 
19+  } 
1420} ) 
1521
1622router . get ( '/:type/:id' ,  async  ctx  =>  { 
17-  let  url  =  ctx . url . replace ( / \/ d o u b a n ( \w * ) / ,  URI  +  '1ドル' ) 
18-  console . log ( ':::' ,  url ,  ':::' ) 
19-  let  result  =  await  request ( { uri : url ,  method : this . method } ) 
20-  ctx . body  =  result . body 
23+  let  result 
24+  try  { 
25+  let  url  =  ctx . url . replace ( / \/ d o u b a n ( \w * ) / ,  URI  +  '1ドル' ) 
26+  console . log ( ':::' ,  url ,  ':::' ) 
27+  result  =  await  request ( { uri : url ,  method : ctx . method } ) 
28+  }  catch  ( error )  { 
29+  throw  new  Error ( error ) 
30+  }  finally  { 
31+  ctx . body  =  result . body 
32+  } 
2133} ) 
2234
2335module . exports  =  router . routes ( ) 
0 commit comments