Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion i18n/messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,8 @@ module.exports = {
round_type: 'Type of round',
round_time_slots: 'Planned timeslots',
round_application_link: 'Application link'
}
},
syllabusErrorMessages: {
syllabus_fetching_error: ({code, time_stamp}) => `Could not create syllabus for ${code}. Time: ${time_stamp}. Please try again later and contact IT support with this error message if the problem persists.`,
},
}
6 changes: 4 additions & 2 deletions i18n/messages.se.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ module.exports = {
round_application_link: 'Anmälningslänk',
round_type: 'Typ av kurstillfälle',
round_time_slots: 'Planerade moduler'
}

},
syllabusErrorMessages: {
syllabus_fetching_error: ({code, time_stamp}) => `Kunde inte skapa kursplan för ${code}. Tidpunkt: ${time_stamp}. Försök igen om ett tag och kontakta IT-support med detta felmeddelande om problemet kvarstår.`,
},
}
7 changes: 6 additions & 1 deletion server/ladokApi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const i18n = require('../i18n')

const { createApiClient } = require('@kth/om-kursen-ladok-client')
const { server: serverConfig } = require('./configuration')

Expand All @@ -11,7 +13,10 @@ async function getLadokSyllabus(courseCode, semester, lang) {

return course
} catch (error) {
throw new Error(error.message)
const languageIndex = lang === 'en' ? 0 : 1
const status = error.response?.status || 500
const message = i18n.messages[languageIndex].syllabusErrorMessages.syllabus_fetching_error({ code: courseCode, time_stamp: new Date().toISOString() })
throw new Error(`Status code ${status}: ${message}`)
}
}

Expand Down
Loading