Hi there,
I'm trying to create an error object for PostgresErrors, and want to have type safety whenever I add a new property.
I have an enum containing all of thePostgres errors, where the key is the error_condition and the value is the error_code, E.G:
UNIQUE_VIOLATION = '23505'
Then I want to have an object/map where the key is the error_code, and the value contains details about that error_code, including the responding error_condition. We already have the relation in the enum, but how can I discriminate this, so that I can only select 1 specific condition_error that relates to the error_code?
const postgresErrors: PostgresErrors = {
'23505': {
errorCondition: '' <- // this can only be 1 specific errorCondition, that relates to 23505
description: 'Duplicate key value violates unique constraint',
translationKey: 'errors.database_errors.unique_violation',
},
};