Move exceptions from interceptor to exception package

This commit is contained in:
Mikołaj Pich 2020-06-10 20:19:31 +02:00
parent 260aa95148
commit be82cb75a0
14 changed files with 23 additions and 17 deletions

View file

@ -1,3 +1,3 @@
package io.github.wulkanowy.sdk.scrapper.interceptor package io.github.wulkanowy.sdk.scrapper.exception
class FeatureDisabledException internal constructor(message: String) : VulcanException(message) class FeatureDisabledException internal constructor(message: String) : VulcanException(message)

View file

@ -1,4 +1,4 @@
package io.github.wulkanowy.sdk.scrapper.interceptor package io.github.wulkanowy.sdk.scrapper.exception
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException

View file

@ -1,5 +1,3 @@
package io.github.wulkanowy.sdk.scrapper.exception package io.github.wulkanowy.sdk.scrapper.exception
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException
class TemporarilyDisabledException(message: String) : VulcanException(message) class TemporarilyDisabledException(message: String) : VulcanException(message)

View file

@ -1,4 +1,4 @@
package io.github.wulkanowy.sdk.scrapper.interceptor package io.github.wulkanowy.sdk.scrapper.exception
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException

View file

@ -2,7 +2,9 @@ package io.github.wulkanowy.sdk.scrapper.interceptor
import io.github.wulkanowy.sdk.scrapper.ApiResponse import io.github.wulkanowy.sdk.scrapper.ApiResponse
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
import io.github.wulkanowy.sdk.scrapper.exception.InvalidPathException import io.github.wulkanowy.sdk.scrapper.exception.InvalidPathException
import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.SingleSource import io.reactivex.SingleSource

View file

@ -1,7 +1,9 @@
package io.github.wulkanowy.sdk.scrapper.interceptor package io.github.wulkanowy.sdk.scrapper.interceptor
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException
import io.github.wulkanowy.sdk.scrapper.exception.ServiceUnavailableException
import io.github.wulkanowy.sdk.scrapper.exception.TemporarilyDisabledException import io.github.wulkanowy.sdk.scrapper.exception.TemporarilyDisabledException
import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException import io.github.wulkanowy.sdk.scrapper.login.AccountPermissionException
import io.github.wulkanowy.sdk.scrapper.login.BadCredentialsException import io.github.wulkanowy.sdk.scrapper.login.BadCredentialsException
import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException
@ -28,7 +30,8 @@ class ErrorInterceptor : Interceptor {
private fun checkForError(doc: Document, redirectUrl: String) { private fun checkForError(doc: Document, redirectUrl: String) {
doc.select(".errorBlock").let { doc.select(".errorBlock").let {
if (it.isNotEmpty()) throw VulcanException("${it.select(".errorTitle").text()}. ${it.select(".errorMessage").text()}") if (it.isNotEmpty()) throw VulcanException("${it.select(".errorTitle")
.text()}. ${it.select(".errorMessage").text()}")
} }
doc.select(".ErrorMessage, #ErrorTextLabel").let { doc.select(".ErrorMessage, #ErrorTextLabel").let {
@ -36,7 +39,8 @@ class ErrorInterceptor : Interceptor {
} }
doc.select("#MainPage_ErrorDiv div").let { doc.select("#MainPage_ErrorDiv div").let {
if (it?.last()?.ownText()?.startsWith("Trwa aktualizacja bazy danych") == true) throw ServiceUnavailableException(it.last().ownText()) if (it?.last()?.ownText()?.startsWith("Trwa aktualizacja bazy danych") == true) throw ServiceUnavailableException(
it.last().ownText())
if (it?.last()?.ownText()?.contains("czasowo wyłączona") == true) throw TemporarilyDisabledException(it.last().ownText()) if (it?.last()?.ownText()?.contains("czasowo wyłączona") == true) throw TemporarilyDisabledException(it.last().ownText())
if (it.isNotEmpty()) throw VulcanException(it[0].ownText()) if (it.isNotEmpty()) throw VulcanException(it[0].ownText())
} }

View file

@ -9,7 +9,7 @@ import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.ADFSLightScoped
import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.AUTO import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.AUTO
import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.STANDARD import io.github.wulkanowy.sdk.scrapper.Scrapper.LoginType.STANDARD
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.register.SendCertificateResponse import io.github.wulkanowy.sdk.scrapper.register.SendCertificateResponse
import io.github.wulkanowy.sdk.scrapper.service.LoginService import io.github.wulkanowy.sdk.scrapper.service.LoginService
import io.reactivex.Single import io.reactivex.Single

View file

@ -5,7 +5,7 @@ import io.github.wulkanowy.sdk.scrapper.ApiResponse
import io.github.wulkanowy.sdk.scrapper.ScrapperException import io.github.wulkanowy.sdk.scrapper.ScrapperException
import io.github.wulkanowy.sdk.scrapper.getScriptParam import io.github.wulkanowy.sdk.scrapper.getScriptParam
import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorHandlerTransformer import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorHandlerTransformer
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.messages.Attachment import io.github.wulkanowy.sdk.scrapper.messages.Attachment
import io.github.wulkanowy.sdk.scrapper.messages.DeleteMessageRequest import io.github.wulkanowy.sdk.scrapper.messages.DeleteMessageRequest
import io.github.wulkanowy.sdk.scrapper.messages.Message import io.github.wulkanowy.sdk.scrapper.messages.Message

View file

@ -1,6 +1,6 @@
package io.github.wulkanowy.sdk.scrapper.repository package io.github.wulkanowy.sdk.scrapper.repository
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.register.Semester import io.github.wulkanowy.sdk.scrapper.register.Semester
import io.github.wulkanowy.sdk.scrapper.service.StudentAndParentService import io.github.wulkanowy.sdk.scrapper.service.StudentAndParentService
import io.reactivex.Observable import io.reactivex.Observable

View file

@ -33,7 +33,7 @@ import io.github.wulkanowy.sdk.scrapper.homework.HomeworkRequest
import io.github.wulkanowy.sdk.scrapper.homework.mapHomework import io.github.wulkanowy.sdk.scrapper.homework.mapHomework
import io.github.wulkanowy.sdk.scrapper.homework.mapHomeworkList import io.github.wulkanowy.sdk.scrapper.homework.mapHomeworkList
import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorHandlerTransformer import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorHandlerTransformer
import io.github.wulkanowy.sdk.scrapper.interceptor.FeatureDisabledException import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
import io.github.wulkanowy.sdk.scrapper.mobile.Device import io.github.wulkanowy.sdk.scrapper.mobile.Device
import io.github.wulkanowy.sdk.scrapper.mobile.TokenResponse import io.github.wulkanowy.sdk.scrapper.mobile.TokenResponse
import io.github.wulkanowy.sdk.scrapper.mobile.UnregisterDeviceRequest import io.github.wulkanowy.sdk.scrapper.mobile.UnregisterDeviceRequest

View file

@ -2,6 +2,8 @@ package io.github.wulkanowy.sdk.scrapper.interceptor
import io.github.wulkanowy.sdk.scrapper.Scrapper import io.github.wulkanowy.sdk.scrapper.Scrapper
import io.github.wulkanowy.sdk.scrapper.BaseLocalTest import io.github.wulkanowy.sdk.scrapper.BaseLocalTest
import io.github.wulkanowy.sdk.scrapper.exception.ServiceUnavailableException
import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.login.LoginTest import io.github.wulkanowy.sdk.scrapper.login.LoginTest
import io.github.wulkanowy.sdk.scrapper.login.NotLoggedInException import io.github.wulkanowy.sdk.scrapper.login.NotLoggedInException
import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException

View file

@ -4,7 +4,7 @@ import io.github.wulkanowy.sdk.scrapper.Scrapper
import io.github.wulkanowy.sdk.scrapper.BaseLocalTest import io.github.wulkanowy.sdk.scrapper.BaseLocalTest
import io.github.wulkanowy.sdk.scrapper.homework.HomeworkTest import io.github.wulkanowy.sdk.scrapper.homework.HomeworkTest
import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorInterceptorTest import io.github.wulkanowy.sdk.scrapper.interceptor.ErrorInterceptorTest
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.register.SendCertificateResponse import io.github.wulkanowy.sdk.scrapper.register.SendCertificateResponse
import io.github.wulkanowy.sdk.scrapper.service.LoginService import io.github.wulkanowy.sdk.scrapper.service.LoginService
import io.reactivex.observers.TestObserver import io.reactivex.observers.TestObserver

View file

@ -1,8 +1,8 @@
package io.github.wulkanowy.sdk.scrapper.timetable package io.github.wulkanowy.sdk.scrapper.timetable
import io.github.wulkanowy.sdk.scrapper.BaseLocalTest import io.github.wulkanowy.sdk.scrapper.BaseLocalTest
import io.github.wulkanowy.sdk.scrapper.interceptor.FeatureDisabledException import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException
import io.github.wulkanowy.sdk.scrapper.register.RegisterTest import io.github.wulkanowy.sdk.scrapper.register.RegisterTest
import io.reactivex.observers.TestObserver import io.reactivex.observers.TestObserver
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals

View file

@ -4,9 +4,9 @@ import io.reactivex.Single
import io.reactivex.SingleSource import io.reactivex.SingleSource
import io.reactivex.SingleTransformer import io.reactivex.SingleTransformer
import io.github.wulkanowy.sdk.scrapper.ScrapperException as ScrapperApiException import io.github.wulkanowy.sdk.scrapper.ScrapperException as ScrapperApiException
import io.github.wulkanowy.sdk.scrapper.interceptor.FeatureDisabledException as ScrapperFeatureDisabledException import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException as ScrapperFeatureDisabledException
import io.github.wulkanowy.sdk.scrapper.interceptor.ServiceUnavailableException as ScrapperServiceUnavailableException import io.github.wulkanowy.sdk.scrapper.exception.ServiceUnavailableException as ScrapperServiceUnavailableException
import io.github.wulkanowy.sdk.scrapper.interceptor.VulcanException as ScrapperVulcanException import io.github.wulkanowy.sdk.scrapper.exception.VulcanException as ScrapperVulcanException
import io.github.wulkanowy.sdk.scrapper.login.BadCredentialsException as ScrapperBadCredentialsException import io.github.wulkanowy.sdk.scrapper.login.BadCredentialsException as ScrapperBadCredentialsException
import io.github.wulkanowy.sdk.scrapper.login.NotLoggedInException as ScrapperNotLoggedInException import io.github.wulkanowy.sdk.scrapper.login.NotLoggedInException as ScrapperNotLoggedInException
import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException as ScrapperPasswordChangeRequiredException import io.github.wulkanowy.sdk.scrapper.login.PasswordChangeRequiredException as ScrapperPasswordChangeRequiredException