refactor: error messages in parsers
This commit is contained in:
parent
d97ca6e517
commit
a7f55fd648
11 changed files with 27 additions and 12 deletions
|
|
@ -77,8 +77,8 @@ class EpubCoverParser @Inject constructor() : CoverParser {
|
|||
}
|
||||
}
|
||||
coverImage
|
||||
} catch (_: Exception) {
|
||||
logE(TAG, "Could not parse cover image.")
|
||||
} catch (e: Exception) {
|
||||
logE(TAG, "Could not parse cover image with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,15 @@ import kotlinx.coroutines.withContext
|
|||
import org.jsoup.Jsoup
|
||||
import org.jsoup.parser.Parser
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.core.log.logE
|
||||
import ua.acclorite.book_story.core.ui.UIText
|
||||
import ua.acclorite.book_story.data.model.file.CachedFile
|
||||
import ua.acclorite.book_story.domain.model.library.Book
|
||||
import java.util.zip.ZipFile
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "EpubFileParser"
|
||||
|
||||
class EpubFileParser @Inject constructor() : FileParser {
|
||||
|
||||
override suspend fun parse(cachedFile: CachedFile): Book? {
|
||||
|
|
@ -76,7 +79,7 @@ class EpubFileParser @Inject constructor() : FileParser {
|
|||
}
|
||||
book
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse file with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@ package ua.acclorite.book_story.data.parser.file
|
|||
import org.jsoup.Jsoup
|
||||
import org.jsoup.parser.Parser
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.core.log.logE
|
||||
import ua.acclorite.book_story.core.ui.UIText
|
||||
import ua.acclorite.book_story.data.model.file.CachedFile
|
||||
import ua.acclorite.book_story.domain.model.library.Book
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "Fb2FileParser"
|
||||
|
||||
class Fb2FileParser @Inject constructor() : FileParser {
|
||||
|
||||
override suspend fun parse(cachedFile: CachedFile): Book? {
|
||||
|
|
@ -56,7 +59,7 @@ class Fb2FileParser @Inject constructor() : FileParser {
|
|||
coverImage = null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse file with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@ package ua.acclorite.book_story.data.parser.file
|
|||
import org.jsoup.Jsoup
|
||||
import org.jsoup.parser.Parser
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.core.log.logE
|
||||
import ua.acclorite.book_story.core.ui.UIText
|
||||
import ua.acclorite.book_story.data.model.file.CachedFile
|
||||
import ua.acclorite.book_story.domain.model.library.Book
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "HtmlFileParser"
|
||||
|
||||
class HtmlFileParser @Inject constructor() : FileParser {
|
||||
|
||||
override suspend fun parse(cachedFile: CachedFile): Book? {
|
||||
|
|
@ -42,7 +45,7 @@ class HtmlFileParser @Inject constructor() : FileParser {
|
|||
coverImage = null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse file with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,11 +10,14 @@ import android.app.Application
|
|||
import com.tom_roush.pdfbox.android.PDFBoxResourceLoader
|
||||
import com.tom_roush.pdfbox.pdmodel.PDDocument
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.core.log.logE
|
||||
import ua.acclorite.book_story.core.ui.UIText
|
||||
import ua.acclorite.book_story.data.model.file.CachedFile
|
||||
import ua.acclorite.book_story.domain.model.library.Book
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "PdfFileParser"
|
||||
|
||||
class PdfFileParser @Inject constructor(
|
||||
private val application: Application
|
||||
) : FileParser {
|
||||
|
|
@ -47,7 +50,7 @@ class PdfFileParser @Inject constructor(
|
|||
coverImage = null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse file with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,14 @@
|
|||
package ua.acclorite.book_story.data.parser.file
|
||||
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.core.log.logE
|
||||
import ua.acclorite.book_story.core.ui.UIText
|
||||
import ua.acclorite.book_story.data.model.file.CachedFile
|
||||
import ua.acclorite.book_story.domain.model.library.Book
|
||||
import javax.inject.Inject
|
||||
|
||||
private const val TAG = "TxtFileParser"
|
||||
|
||||
class TxtFileParser @Inject constructor() : FileParser {
|
||||
|
||||
override suspend fun parse(cachedFile: CachedFile): Book? {
|
||||
|
|
@ -31,7 +34,7 @@ class TxtFileParser @Inject constructor() : FileParser {
|
|||
coverImage = null
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse file with message: ${e.message}.")
|
||||
null
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ class EpubTextParser @Inject constructor(
|
|||
logI(TAG, "Successfully finished EPUB parsing.")
|
||||
readerText
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
logE(TAG, "Could not parse text with message: ${e.message}.")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class HtmlTextParser @Inject constructor(
|
|||
logI(TAG, "Successfully finished HTML parsing.")
|
||||
readerText
|
||||
} catch (e: Exception) {
|
||||
logE(TAG, e.message ?: "")
|
||||
logE(TAG, "Could not parse text with message: ${e.message}.")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ class PdfTextParser @Inject constructor(
|
|||
logI(TAG, "Successfully finished PDF parsing.")
|
||||
readerText
|
||||
} catch (e: Exception) {
|
||||
logE(TAG, e.message ?: "")
|
||||
logE(TAG, "Could not parse text with message: ${e.message}.")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class TxtTextParser @Inject constructor(
|
|||
logI(TAG, "Successfully finished TXT parsing.")
|
||||
readerText
|
||||
} catch (e: Exception) {
|
||||
logE(TAG, e.message ?: "")
|
||||
logE(TAG, "Could not parse text with message: ${e.message}.")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class XmlTextParser @Inject constructor(
|
|||
logI(TAG, "Successfully finished XML parsing.")
|
||||
readerText
|
||||
} catch (e: Exception) {
|
||||
logE(TAG, e.message ?: "")
|
||||
logE(TAG, "Could not parse text with message: ${e.message}.")
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue