@sprucelabs/spruce-file-utils 15.1.6 → 15.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ import AbstractSpruceError from '@sprucelabs/error';
2
+ import ErrorOptions from './../.spruce/errors/options.types';
3
+ export default class SpruceError extends AbstractSpruceError<ErrorOptions> {
4
+ friendlyMessage(): string;
5
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const error_1 = __importDefault(require("@sprucelabs/error"));
7
+ class SpruceError extends error_1.default {
8
+ friendlyMessage() {
9
+ const { options } = this;
10
+ let message;
11
+ switch (options?.code) {
12
+ case 'UNAUTHORIZED':
13
+ message = 'You are not authorized to perform this action.';
14
+ break;
15
+ case 'BAD_REQUEST':
16
+ message = 'A Bad request just happened!';
17
+ break;
18
+ default:
19
+ message = super.friendlyMessage();
20
+ }
21
+ const fullMessage = options.friendlyMessage
22
+ ? options.friendlyMessage
23
+ : message;
24
+ return fullMessage;
25
+ }
26
+ }
27
+ exports.default = SpruceError;
@@ -10,7 +10,7 @@ class MockChunkingUploader extends mercury_event_emitter_1.AbstractEventEmitter
10
10
  MockChunkingUploader.instance = this;
11
11
  }
12
12
  static assertWasCreated() {
13
- test_utils_1.assert.isTruthy(MockChunkingUploader.instance, 'You need to intantiate ChunkingUploaderImpl.Uploader(this.connectApi).');
13
+ test_utils_1.assert.isTruthy(MockChunkingUploader.instance, 'You need to instantiate ChunkingUploaderImpl.Uploader(()=>this.connectApi()).');
14
14
  }
15
15
  assertFileEqualsLastReturnedFromUpload(file) {
16
16
  (0, schema_1.assertOptions)({ file }, ['file']);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sprucelabs/spruce-file-utils",
3
3
  "description": "Utils for working with files and Sprucebot.",
4
- "version": "15.1.6",
4
+ "version": "15.1.8",
5
5
  "skill": {
6
6
  "namespace": "files"
7
7
  },
@@ -31,6 +31,8 @@
31
31
  "build/uploading/ChunkingUploader.js",
32
32
  "build/uploading/MockChunkingUploader.d.ts",
33
33
  "build/uploading/MockChunkingUploader.js",
34
+ "build/errors/SpruceError.d.ts",
35
+ "build/errors/SpruceError.js",
34
36
 
35
37
  "build/esm/uploading/LocalUploadStrategy.d.ts",
36
38
  "build/esm/uploading/LocalUploadStrategy.js",
@@ -41,6 +43,7 @@
41
43
  "build/esm/uploading/S3UploadStrategy.js",
42
44
  "build/uploading/S3UploadStrategy.d.ts",
43
45
  "build/uploading/S3UploadStrategy.js"
46
+
44
47
 
45
48
  ],
46
49
  "keywords": [],