File size: 1,042 Bytes
a5d718a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/**

 * The type of error that occurred.

 * @public

 */
export type ErrorType = 'invalid-retry' | 'unknown-field' | 'max-buffer-size-exceeded'

/**

 * Error thrown when encountering an issue during parsing.

 *

 * @public

 */
export class ParseError extends Error {
  /**

   * The type of error that occurred.

   */
  type: ErrorType

  /**

   * In the case of an unknown field encountered in the stream, this will be the field name.

   */
  field?: string | undefined

  /**

   * In the case of an unknown field encountered in the stream, this will be the value of the field.

   */
  value?: string | undefined

  /**

   * The line that caused the error, if available.

   */
  line?: string | undefined

  constructor(

    message: string,

    options: {type: ErrorType; field?: string; value?: string; line?: string},

  ) {
    super(message)
    this.name = 'ParseError'
    this.type = options.type
    this.field = options.field
    this.value = options.value
    this.line = options.line
  }
}