<commit_before>import {Component, Inject, Injectable, AfterViewInit, ViewChild, ElementRef} from '@angular/core';
import DataService from '../../service/msp-data.service';
import {MspApiService} from "../../service/msp-api.service";
import {Router} from "@angular/router";
import {ResponseType} from "../../api-model/responseTypes";
import {FinancialAssistApplication} from "../../model/financial-assist-application.model";
import {MspLogService} from '../../service/log.service'

@Component({
  templateUrl: 'sending.component.html'
})
@Injectable()
export class AssistanceSendingComponent implements AfterViewInit  {
  lang = require('./i18n');

  application:FinancialAssistApplication;
  rawUrl: string;
  rawError: string;
  rawRequest: string;

  transmissionInProcess:boolean;
  errorCode:string;
  showMoreErrorDetails:boolean;

  constructor(private dataService: DataService, 
              private service:MspApiService, 
              public router: Router,
              public logService:MspLogService) {
    this.application = this.dataService.finAssistApp;
  }

  ngAfterViewInit() {
    // console.log('PA uuid before: ' + this.application.uuid);
    this.application.regenUUID();
    this.dataService.saveFinAssistApplication();
    // console.log('PA uuid after: ' + this.application.uuid);
    
    // After view inits, begin sending the application
    this.transmissionInProcess = true;
    this.errorCode = undefined;
    
    // After view inits, begin sending the application
    this.service
      .sendApplication(this.application)
      .then((application:FinancialAssistApplication) => {
        this.application = application;

        this.logService.log({name: 'premium assistance application received success confirmation from API server', 
          confirmationNumber: this.application.referenceNumber});

        //delete the premium assistance application content from local storage
        this.dataService.removeFinAssistApplication();

        //  go to confirmation
        this.router.navigate(["/msp/assistance/confirmation"], 
          {queryParams: {confirmationNum:this.application.referenceNumber}});
        
      })
      .catch((error: ResponseType | any) => {
        console.log('Error in sending PA: %o', error);
        this.errorCode = error.status + '';
        
        this.rawUrl = error.url;
        this.rawError = error._body;
        this.rawRequest = error._requestBody;

        this.logService.log({name: 'premium assistance application received failure message from API server', 
          error: error._body,
          request: error._requestBody});
        this.transmissionInProcess = false;
        // this.router.navigate(["/msp/assistance/confirmation"]);
        this.application.authorizationToken = null;
      });
  }

  toggleErrorDetails(){
    this.showMoreErrorDetails = !this.showMoreErrorDetails;
  }
  <commit_msg>output the entire error in PA<commit_after>import {Component, Inject, Injectable, AfterViewInit, ViewChild, ElementRef} from '@angular/core';
import DataService from '../../service/msp-data.service';
import {MspApiService} from "../../service/msp-api.service";
import {Router} from "@angular/router";
import {ResponseType} from "../../api-model/responseTypes";
import {FinancialAssistApplication} from "../../model/financial-assist-application.model";
import {MspLogService} from '../../service/log.service'

@Component({
  templateUrl: 'sending.component.html'
})
@Injectable()
export class AssistanceSendingComponent implements AfterViewInit  {
  lang = require('./i18n');

  application:FinancialAssistApplication;
  rawUrl: string;
  rawError: string;
  rawRequest: string;

  transmissionInProcess:boolean;
  errorCode:string;
  showMoreErrorDetails:boolean;

  constructor(private dataService: DataService, 
              private service:MspApiService, 
              public router: Router,
              public logService:MspLogService) {
    this.application = this.dataService.finAssistApp;
  }

  ngAfterViewInit() {
    // console.log('PA uuid before: ' + this.application.uuid);
    this.application.regenUUID();
    this.dataService.saveFinAssistApplication();
    // console.log('PA uuid after: ' + this.application.uuid);
    
    // After view inits, begin sending the application
    this.transmissionInProcess = true;
    this.errorCode = undefined;
    
    // After view inits, begin sending the application
    this.service
      .sendApplication(this.application)
      .then((application:FinancialAssistApplication) => {
        this.application = application;

        this.logService.log({name: 'premium assistance application received success confirmation from API server', 
          confirmationNumber: this.application.referenceNumber});

        //delete the premium assistance application content from local storage
        this.dataService.removeFinAssistApplication();

        //  go to confirmation
        this.router.navigate(["/msp/assistance/confirmation"], 
          {queryParams: {confirmationNum:this.application.referenceNumber}});
        
      })
      .catch((error: ResponseType | any) => {
        console.log('Error in sending PA: %o', error);
        this.errorCode = error.status + '';
        
        this.rawUrl = error.url;
        this.rawError = error;
        this.rawRequest = error._requestBody;

        this.logService.log({name: 'premium assistance application received failure message from API server', 
          error: error._body,
          request: error._requestBody});
        this.transmissionInProcess = false;
        // this.router.navigate(["/msp/assistance/confirmation"]);
        this.application.authorizationToken = null;
      });
  }

  toggleErrorDetails(){
    this.showMoreErrorDetails = !this.showMoreErrorDetails;
  }
  
{'fraction_non_alphanumeric': 0.11621900826446281, 'fraction_numerical': 0.0006887052341597796, 'mean_word_length': 3.2619222303741746, 'pattern_counts': {'":': 0, '<': 3, '<?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': '1692555', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1535, 'n_words': 339}