{% if RequiresClientFunctions -%}
{% if Framework.IsAngular -%}
function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): Observable<any> {
{%     if WrapDtoExceptions -%}
    return {{ Framework.RxJs.ObservableThrowMethod }}(new {{ ExceptionClassName }}(message, status, response, headers, result));
{%-     else -%}
    if (result !== null && result !== undefined)
        return {{ Framework.RxJs.ObservableThrowMethod }}(result);
    else
        return {{ Framework.RxJs.ObservableThrowMethod }}(new {{ ExceptionClassName }}(message, status, response, headers, null));
{%     endif -%}
}

{% elsif Framework.IsAngularJS -%}
function throwException(q: ng.IQService, message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): ng.IPromise<any> {
{%     if WrapDtoExceptions -%}
    return q.reject(new {{ ExceptionClassName }}(message, status, response, headers, result));
{%-     else -%}
    if (result !== null && result !== undefined)
        return q.reject(result);
    else
        return q.reject(new {{ ExceptionClassName }}(message, status, response, headers, null));
{%     endif -%}
}

{% else -%}
function throwException(message: string, status: number, response: string, headers: { [key: string]: any; }, result?: any): any {
{%     if WrapDtoExceptions -%}
    throw new {{ ExceptionClassName }}(message, status, response, headers, result);
{%-     else -%}
    if (result !== null && result !== undefined)
        throw result;
    else
        throw new {{ ExceptionClassName }}(message, status, response, headers, null);
{%     endif -%}
}

{%- endif -%}
{% if Framework.IsAngular -%}
function blobToText(blob: any): Observable<string> {
    return new Observable<string>((observer: any) => {
        if (!blob) {
            observer.next("");
            observer.complete();
        } else {
            let reader = new FileReader();
            reader.onload = event => {
                observer.next((event.target as any).result);
                observer.complete();
            };
            reader.readAsText(blob);
        }
    });
}

{% elsif Framework.IsAngularJS -%}
function blobToText(blob: Blob, q: ng.IQService): ng.IPromise<string> {
    return new q((resolve) => {
        let reader = new FileReader();
        reader.onload = event => resolve((event.target as any).result);
        reader.readAsText(blob);
    });
}

{% elsif Framework.IsAxios -%}
function isAxiosError(obj: any): obj is AxiosError {
    return obj && obj.isAxiosError === true;
}

{% endif -%}
{% endif -%}