refactor: updates error handling

This commit is contained in:
eugene 2024-08-29 19:21:52 +03:00
parent 791c213e3a
commit b965623a02

View File

@ -145,11 +145,20 @@ export class MetadataController extends EventEmitter {
* or a fallback RelaySet with Sigit's Relay
*/
public findRelayListMetadata = async (hexKey: string): Promise<RelaySet> => {
const relayEvent =
(await findRelayListInCache(hexKey)) ||
(await findRelayListAndUpdateCache(DEFAULT_LOOK_UP_RELAY_LIST, hexKey))
try {
const relayEvent =
(await findRelayListInCache(hexKey)) ||
(await findRelayListAndUpdateCache(DEFAULT_LOOK_UP_RELAY_LIST, hexKey))
return relayEvent ? getUserRelaySet(relayEvent.tags) : getDefaultRelaySet()
return relayEvent
? getUserRelaySet(relayEvent.tags)
: getDefaultRelaySet()
} catch (error) {
throw new Error(
`An error occurred while finding relay list metadata for ${hexKey}`,
{ cause: error }
)
}
}
public extractProfileMetadataContent = (event: Event) => {