<?php

final class PhutilJSONParserException extends Exception {

  private $sourceLine;
  private $sourceChar;
  private $sourceToken;
  private $expected;

  public function __construct(
    $message,
    $line = null,
    $char = null,
    $token = null,
    $expected = null) {

    $this->sourceLine = $line;
    $this->sourceChar = $char;
    $this->sourceToken = $token;
    $this->expected = $expected;

    parent::__construct($message);
  }

  public function getSourceLine() {
    return $this->sourceLine;
  }

  public function getSourceChar() {
    return $this->sourceChar;
  }

  public function getSourceToken() {
    return $this->sourceToken;
  }

  public function getExpectedTokens() {
    return $this->expected;
  }

}

<?php

final class PhutilJSONParserException extends Exception {

  private $sourceLine;
  private $sourceChar;
  private $sourceToken;
  private $expected;

  public function __construct(
    $message,
    $line = null,
    $char = null,
    $token = null,
    $expected = null) {

    $this->sourceLine = $line;
    $this->sourceChar = $char;
    $this->sourceToken = $token;
    $this->expected = $expected;

    parent::__construct(
      pht('Parse error on line %d at column %d: %s', $line, $char, $message));
  }

  public function getSourceLine() {
    return $this->sourceLine;
  }

  public function getSourceChar() {
    return $this->sourceChar;
  }

  public function getSourceToken() {
    return $this->sourceToken;
  }

  public function getExpectedTokens() {
    return $this->expected;
  }

}

Improve the exception message for JSON parsing exceptions.
Improve the exception message for JSON parsing exceptions.

Summary: Provide contextual information relating to JSON parser exceptions.

Test Plan: See D9679.

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: epriestley, Korvin

Differential Revision: https://secure.phabricator.com/D9680
