<commit_before>﻿/// <reference path="../../foundation.core.htmlclient/foundation.core.d.ts" />
module Foundation.ViewModel.Implementations {
    @Core.Injectable()
    export class DefaultMetadataProvider implements Contracts.IMetadataProvider {

        private appMetadata: Contracts.AppMetadata = null;

        public constructor( @Core.Inject("ClientAppProfileManager") public clientAppProfileManager: Core.ClientAppProfileManager) {

        }

        @Core.Log()
        public async getMetadata(): Promise<Contracts.AppMetadata> {

            if (this.appMetadata == null)
                this.appMetadata = (await (await fetch(`Metadata/V${this.clientAppProfileManager.getClientAppProfile().version}`, { credentials: 'include' })).json()) as any;

            return this.appMetadata;
        }
    }
}<commit_msg>throw error in case of server side error while loading metadata<commit_after>﻿/// <reference path="../../foundation.core.htmlclient/foundation.core.d.ts" />
module Foundation.ViewModel.Implementations {
    @Core.Injectable()
    export class DefaultMetadataProvider implements Contracts.IMetadataProvider {

        private appMetadata: Contracts.AppMetadata = null;

        public constructor( @Core.Inject("ClientAppProfileManager") public clientAppProfileManager: Core.ClientAppProfileManager) {

        }

        @Core.Log()
        public async getMetadata(): Promise<Contracts.AppMetadata> {

            if (this.appMetadata == null) {
                let response = await fetch(`Metadata/V${this.clientAppProfileManager.getClientAppProfile().version}`, { credentials: 'include' });
                if (response.ok) {
                    this.appMetadata = await response.json() as any;
                }
                else {
                    throw new Error("Error retriving metadata");
                }
            }

            return this.appMetadata;
        }
    }
}
{'fraction_non_alphanumeric': 0.11064718162839249, 'fraction_numerical': 0.0, 'mean_word_length': 2.6306818181818183, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3878080', 'n_tokens_mistral': 483, 'n_tokens_neox': 467, 'n_words': 100}