github.com/pion/webrtc/v4@v4.0.1/pkg/rtcerr/errors.go (about)

     1  // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
     2  // SPDX-License-Identifier: MIT
     3  
     4  // Package rtcerr implements the error wrappers defined throughout the
     5  // WebRTC 1.0 specifications.
     6  package rtcerr
     7  
     8  import (
     9  	"fmt"
    10  )
    11  
    12  // UnknownError indicates the operation failed for an unknown transient reason.
    13  type UnknownError struct {
    14  	Err error
    15  }
    16  
    17  func (e *UnknownError) Error() string {
    18  	return fmt.Sprintf("UnknownError: %v", e.Err)
    19  }
    20  
    21  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    22  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    23  func (e *UnknownError) Unwrap() error {
    24  	return e.Err
    25  }
    26  
    27  // InvalidStateError indicates the object is in an invalid state.
    28  type InvalidStateError struct {
    29  	Err error
    30  }
    31  
    32  func (e *InvalidStateError) Error() string {
    33  	return fmt.Sprintf("InvalidStateError: %v", e.Err)
    34  }
    35  
    36  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    37  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    38  func (e *InvalidStateError) Unwrap() error {
    39  	return e.Err
    40  }
    41  
    42  // InvalidAccessError indicates the object does not support the operation or
    43  // argument.
    44  type InvalidAccessError struct {
    45  	Err error
    46  }
    47  
    48  func (e *InvalidAccessError) Error() string {
    49  	return fmt.Sprintf("InvalidAccessError: %v", e.Err)
    50  }
    51  
    52  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    53  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    54  func (e *InvalidAccessError) Unwrap() error {
    55  	return e.Err
    56  }
    57  
    58  // NotSupportedError indicates the operation is not supported.
    59  type NotSupportedError struct {
    60  	Err error
    61  }
    62  
    63  func (e *NotSupportedError) Error() string {
    64  	return fmt.Sprintf("NotSupportedError: %v", e.Err)
    65  }
    66  
    67  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    68  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    69  func (e *NotSupportedError) Unwrap() error {
    70  	return e.Err
    71  }
    72  
    73  // InvalidModificationError indicates the object cannot be modified in this way.
    74  type InvalidModificationError struct {
    75  	Err error
    76  }
    77  
    78  func (e *InvalidModificationError) Error() string {
    79  	return fmt.Sprintf("InvalidModificationError: %v", e.Err)
    80  }
    81  
    82  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    83  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    84  func (e *InvalidModificationError) Unwrap() error {
    85  	return e.Err
    86  }
    87  
    88  // SyntaxError indicates the string did not match the expected pattern.
    89  type SyntaxError struct {
    90  	Err error
    91  }
    92  
    93  func (e *SyntaxError) Error() string {
    94  	return fmt.Sprintf("SyntaxError: %v", e.Err)
    95  }
    96  
    97  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
    98  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
    99  func (e *SyntaxError) Unwrap() error {
   100  	return e.Err
   101  }
   102  
   103  // TypeError indicates an error when a value is not of the expected type.
   104  type TypeError struct {
   105  	Err error
   106  }
   107  
   108  func (e *TypeError) Error() string {
   109  	return fmt.Sprintf("TypeError: %v", e.Err)
   110  }
   111  
   112  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
   113  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
   114  func (e *TypeError) Unwrap() error {
   115  	return e.Err
   116  }
   117  
   118  // OperationError indicates the operation failed for an operation-specific
   119  // reason.
   120  type OperationError struct {
   121  	Err error
   122  }
   123  
   124  func (e *OperationError) Error() string {
   125  	return fmt.Sprintf("OperationError: %v", e.Err)
   126  }
   127  
   128  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
   129  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
   130  func (e *OperationError) Unwrap() error {
   131  	return e.Err
   132  }
   133  
   134  // NotReadableError indicates the input/output read operation failed.
   135  type NotReadableError struct {
   136  	Err error
   137  }
   138  
   139  func (e *NotReadableError) Error() string {
   140  	return fmt.Sprintf("NotReadableError: %v", e.Err)
   141  }
   142  
   143  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
   144  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
   145  func (e *NotReadableError) Unwrap() error {
   146  	return e.Err
   147  }
   148  
   149  // RangeError indicates an error when a value is not in the set or range
   150  // of allowed values.
   151  type RangeError struct {
   152  	Err error
   153  }
   154  
   155  func (e *RangeError) Error() string {
   156  	return fmt.Sprintf("RangeError: %v", e.Err)
   157  }
   158  
   159  // Unwrap returns the result of calling the Unwrap method on err, if err's type contains
   160  // an Unwrap method returning error. Otherwise, Unwrap returns nil.
   161  func (e *RangeError) Unwrap() error {
   162  	return e.Err
   163  }