<commit_before><?php

/**
 * An exception specifically for API use.
 * Messages are hidden from the user if the Exception is not caught, a default
 * one set by the code is used instead
 * @author <NAME>
 * @copyright <NAME>, 2014
 */

namespace Gisleburt\Api;

class Exception extends \Exception implements \JsonSerializable
{

    const DEFAULT_ERROR_CODE = 500;
    const DEFAULT_MESSAGE = 'Internal Server Error';

    /**
     * @var string
     */
    public $publicMessage;

    /**
     * @param string $message Message to put into the log
     * @param int $code HTTP Status code to send to the user
     * @param string $publicMessage Message to show the user if different from the message associated with the status code
     * @param \Exception $previous Any previous Exception
     */
    public function __construct($message, $code = 500, $publicMessage = '', \Exception $previous = null) {
        $this->publicMessage = $publicMessage;
        if(!$publicMessage) {
            $this->publicMessage = static::DEFAULT_MESSAGE;
            if(in_array($code, Status::$statusCodes)) {
                $this->publicMessage = Status::$statusCodes[$code];
            }
        }
        parent::__construct($message, $code, $previous);
    }

    public function getPublicMessage() {
        return $this->publicMessage;
    }

    public function jsonSerialize() {
        return [
            'message' => $this->getMessage(),
            'code' => $this->getCode(),
            'previous' => $this->getPrevious(),
        ];
    }

}<commit_msg>Fixed public message.<commit_after><?php

/**
 * An exception specifically for API use.
 * Messages are hidden from the user if the Exception is not caught, a default
 * one set by the code is used instead
 * @author <NAME>
 * @copyright <NAME>, 2014
 */

namespace Gisleburt\Api;

class Exception extends \Exception implements \JsonSerializable
{

    const DEFAULT_ERROR_CODE = 500;
    const DEFAULT_MESSAGE = 'Internal Server Error';

    /**
     * @var string
     */
    public $publicMessage;

    /**
     * @param string $message Message to put into the log
     * @param int $code HTTP Status code to send to the user
     * @param string $publicMessage Message to show the user if different from the message associated with the status code
     * @param \Exception $previous Any previous Exception
     */
    public function __construct($message, $code = 500, $publicMessage = '', \Exception $previous = null) {
        $this->publicMessage = $publicMessage;
        if(!$publicMessage) {
            $this->publicMessage = Status::getMessageForCode($code);
            if(!$this->publicMessage) {
                $this->publicMessage = static::DEFAULT_MESSAGE;
            }
        }
        parent::__construct($message, $code, $previous);
    }

    public function getPublicMessage() {
        return $this->publicMessage;
    }

    public function jsonSerialize() {
        return [
            'message' => $this->getMessage(),
            'code' => $this->getCode(),
            'previous' => $this->getPrevious(),
        ];
    }

} 
{'fraction_non_alphanumeric': 0.11200256739409499, 'fraction_numerical': 0.006418485237483954, 'mean_word_length': 2.5868814729574225, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 28, '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': '4188364', 'n_tokens_mistral': 828, 'n_tokens_neox': 805, 'n_words': 269}