Skip to content

Commit

Permalink
try-catch block added
Browse files Browse the repository at this point in the history
  • Loading branch information
bakshiutkarsha committed May 26, 2020
1 parent 8730bc6 commit eb771c3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Downloader from '../src/Downloader';
import { Dump } from '../src/Dump';
import axios from 'axios';
import execa = require('execa');
import logger from '../src/Logger';

export function leftPad(_num: number, length: number) {
const num = `${_num}`;
Expand Down Expand Up @@ -67,9 +68,13 @@ export async function zimcheck(filePath: string) {
}

export async function convertWikicodeToHtml(wikicode: string, baseUrl: string): Promise<string> {
const resp = await axios.post(`${baseUrl}api/rest_v1/transform/wikitext/to/html`, {
wikitext: wikicode,
body_only: true,
})
return resp.data;
try {
const resp = await axios.post(`${baseUrl}api/rest_v1/transform/wikitext/to/html`, {
wikitext: wikicode,
body_only: true,
})
return resp.data;
} catch (err){
logger.log(`Got err during conversion of wikicode to HTML due to ${err}`);
}
}

0 comments on commit eb771c3

Please sign in to comment.