remove unneeded dependency, use try catch when writing files
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-06-06 20:53:23 +02:00
parent 8d9fcd3d7c
commit fe72c02562
2 changed files with 8 additions and 5 deletions

View File

@ -190,12 +190,16 @@ class CacheController {
* @param timetable a timetable of the type [TimetableCourseWeek]
*/
private fun saveTimetableToCache(timetable: TimetableCourseWeek) {
println(timetable.timetable.toString())
val file = File(StartupController.dirTcorCache, "timetable-${timetable.meta.courseName}-${timetable.meta.weekIndex}.json")
val writer = BufferedWriter(FileWriter(file))
writer.write(Gson().toJson(timetable))
writer.close()
try {
writer.write(Gson().toJson(timetable))
} catch (e: Exception) {
logger.error("something went wrong while trying to write a cache file", e)
} finally {
writer.close()
}
}
/**