errors.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * MinIO Javascript Library for Amazon S3 Compatible Cloud Storage, (C) 2015 MinIO, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /// <reference lib="ES2022.Error" />
  17. class ExtendableError extends Error {
  18. constructor(message?: string, opt?: ErrorOptions) {
  19. // error Option {cause?: unknown} is a 'nice to have',
  20. // don't use it internally
  21. super(message, opt)
  22. // set error name, otherwise it's always 'Error'
  23. this.name = this.constructor.name
  24. }
  25. }
  26. /**
  27. * AnonymousRequestError is generated for anonymous keys on specific
  28. * APIs. NOTE: PresignedURL generation always requires access keys.
  29. */
  30. export class AnonymousRequestError extends ExtendableError {}
  31. /**
  32. * InvalidArgumentError is generated for all invalid arguments.
  33. */
  34. export class InvalidArgumentError extends ExtendableError {}
  35. /**
  36. * InvalidPortError is generated when a non integer value is provided
  37. * for ports.
  38. */
  39. export class InvalidPortError extends ExtendableError {}
  40. /**
  41. * InvalidEndpointError is generated when an invalid end point value is
  42. * provided which does not follow domain standards.
  43. */
  44. export class InvalidEndpointError extends ExtendableError {}
  45. /**
  46. * InvalidBucketNameError is generated when an invalid bucket name is
  47. * provided which does not follow AWS S3 specifications.
  48. * http://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
  49. */
  50. export class InvalidBucketNameError extends ExtendableError {}
  51. /**
  52. * InvalidObjectNameError is generated when an invalid object name is
  53. * provided which does not follow AWS S3 specifications.
  54. * http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
  55. */
  56. export class InvalidObjectNameError extends ExtendableError {}
  57. /**
  58. * AccessKeyRequiredError generated by signature methods when access
  59. * key is not found.
  60. */
  61. export class AccessKeyRequiredError extends ExtendableError {}
  62. /**
  63. * SecretKeyRequiredError generated by signature methods when secret
  64. * key is not found.
  65. */
  66. export class SecretKeyRequiredError extends ExtendableError {}
  67. /**
  68. * ExpiresParamError generated when expires parameter value is not
  69. * well within stipulated limits.
  70. */
  71. export class ExpiresParamError extends ExtendableError {}
  72. /**
  73. * InvalidDateError generated when invalid date is found.
  74. */
  75. export class InvalidDateError extends ExtendableError {}
  76. /**
  77. * InvalidPrefixError generated when object prefix provided is invalid
  78. * or does not conform to AWS S3 object key restrictions.
  79. */
  80. export class InvalidPrefixError extends ExtendableError {}
  81. /**
  82. * InvalidBucketPolicyError generated when the given bucket policy is invalid.
  83. */
  84. export class InvalidBucketPolicyError extends ExtendableError {}
  85. /**
  86. * IncorrectSizeError generated when total data read mismatches with
  87. * the input size.
  88. */
  89. export class IncorrectSizeError extends ExtendableError {}
  90. /**
  91. * InvalidXMLError generated when an unknown XML is found.
  92. */
  93. export class InvalidXMLError extends ExtendableError {}
  94. /**
  95. * S3Error is generated for errors returned from S3 server.
  96. * see getErrorTransformer for details
  97. */
  98. export class S3Error extends ExtendableError {
  99. code?: string
  100. region?: string
  101. }
  102. export class IsValidBucketNameError extends ExtendableError {}