<commit_before>//
//  UIAlertController+APIError.swift
//  Digipost
//
//  Created by <NAME> on 04/02/15.
//  Copyright (c) 2015 Posten. All rights reserved.
//

import UIKit

extension UIAlertController {
    
    class func presentAlertControllerWithAPIError(apiError: APIError, presentingViewController: UIViewController) {
        if apiError.shouldBeShownToUser {
            let alertController = UIAlertController(title: apiError.alertTitle, message: apiError.altertMessage, preferredStyle: UIAlertControllerStyle.Alert)
            
            let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
                
            })
            
            alertController.addAction(okAction)
            presentingViewController.presentViewController(alertController, animated: true, completion: { () -> Void in
                
            })
        }
    }
    
    class func presentAlertControllerWithAPIError(apiError: APIError, presentingViewController: UIViewController, didTapOkClosure: () -> Void ) {
        if apiError.shouldBeShownToUser {
            let alertController = UIAlertController(title: apiError.alertTitle, message: apiError.altertMessage, preferredStyle: UIAlertControllerStyle.Alert)
            
            let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
                didTapOkClosure()
            })
            <commit_msg>clean class description before logging it<commit_after>//
//  UIAlertController+APIError.swift
//  Digipost
//
//  Created by <NAME> on 04/02/15.
//  Copyright (c) 2015 Posten. All rights reserved.
//

import UIKit

extension UIAlertController {
    
    class func presentAlertControllerWithAPIError(apiError: APIError, presentingViewController: UIViewController) {
        if apiError.shouldBeShownToUser {

            let alertController = UIAlertController(title: apiError.alertTitle, message: apiError.altertMessage, preferredStyle: UIAlertControllerStyle.Alert)
            
            let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
                
            })
            
            alertController.addAction(okAction)
            presentingViewController.presentViewController(alertController, animated: true, completion: { () -> Void in
                
            })

            var descriptionWithNoForbiddenCharacters = "\(presentingViewController)".stringByReplacingOccurrencesOfString("<", withString: "")
            descriptionWithNoForbiddenCharacters = descriptionWithNoForbiddenCharacters.stringByReplacingOccurrencesOfString(">", withString: "")
            Logger.dpostLogError("API error shown to user, code:\(apiError.code), digipostErrorcode: \(apiError.digipostErrorCode) VC: \(descriptionWithNoForbiddenCharacters) ")
        }
    }
    
    class func presentAlertControllerWithAPIError(apiError: APIError, presentingViewController: UIViewController, didTapOkClosure: () -> Void ) {
        if apiError.shouldBeShownToUser {
            let alertController = UIAlertController(title: apiError.alertTitle, message: apiError.altertMessage, preferredStyle: UIAlertControllerStyle.Alert)
            
            let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: { (alertAction) -> Void in
                didTapOkClosure()
            })
            
{'fraction_non_alphanumeric': 0.08685648547598504, 'fraction_numerical': 0.005752085130859937, 'mean_word_length': 2.9034792368125704, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 14, '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': '3617935', 'n_tokens_mistral': 918, 'n_tokens_neox': 873, 'n_words': 184}