File tree Expand file tree Collapse file tree 6 files changed +19
-8
lines changed Expand file tree Collapse file tree 6 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -44,9 +44,9 @@ const subscribe = async (auth) => {
44
44
try {
45
45
webhook . subscribe ( auth ) ;
46
46
} catch ( e ) {
47
- switch ( e . constructor . name ) {
48
- case UserSubscriptionError . name :
49
- console . error ( e . getMessage ( ) ) ;
47
+ switch ( e . constructor ) {
48
+ case UserSubscriptionError :
49
+ console . error ( e . message ) ;
50
50
break ;
51
51
}
52
52
@@ -64,15 +64,15 @@ const subscribe = async (auth) => {
64
64
try {
65
65
await webhook . start ( argv . webhookUrl || null ) ;
66
66
} catch ( e ) {
67
- switch ( e . constructor . name ) {
68
- case TooManyWebhooksError . name :
67
+ switch ( e . constructor ) {
68
+ case TooManyWebhooksError :
69
69
console . error ( 'Cannot add webhook: you have exceeded the number of webhooks available' ,
70
70
`to you for the '${ argv . env || process . env . TWITTER_WEBHOOK_ENV } ' environment.` ,
71
71
`Use 'autohook -r' to remove your existing webhooks or remove callbacks manually` ,
72
72
'using the Twitter API.' ) ;
73
73
break ;
74
74
default :
75
- console . error ( 'Error:' , e . getMessage ( ) ) ;
75
+ console . error ( 'Error:' , e . message ) ;
76
76
break ;
77
77
}
78
78
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class RateLimitError extends Error {
46
46
Error . captureStackTrace ( this , this . constructor ) ;
47
47
}
48
48
}
49
- class TooManySubscriptionsError extends Error { }
49
+ class TooManySubscriptionsError extends TwitterError { }
50
50
51
51
module . exports = {
52
52
TwitterError,
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ const crypto = require('crypto');
9
9
const path = require ( 'path' ) ;
10
10
const os = require ( 'os' ) ;
11
11
const EventEmitter = require ( 'events' ) ;
12
+ const URL = require ( 'url' ) . URL ;
13
+
12
14
const {
13
15
TooManySubscriptionsError,
14
16
UserSubscriptionError,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " twitter-autohook" ,
3
- "version" : " 1.4.1 " ,
3
+ "version" : " 1.4.2 " ,
4
4
"description" : " Automatically setup and serve webhooks for the Twitter Account Activity API" ,
5
5
"repository" : {
6
6
"type" : " git" ,
Original file line number Diff line number Diff line change 3
3
UserSubscriptionError,
4
4
WebhookURIError,
5
5
RateLimitError,
6
+ TooManySubscriptionsError,
6
7
} = require ( '../errors' ) ;
7
8
const response = {
8
9
statusCode : 200 ,
@@ -30,6 +31,7 @@ const assert = (e) => {
30
31
31
32
console . log ( e . code === 1337 ) ;
32
33
}
34
+
33
35
try {
34
36
throw new TwitterError ( response ) ;
35
37
} catch ( e ) {
53
55
} catch ( e ) {
54
56
assert ( e ) ;
55
57
}
58
+
59
+ try {
60
+ throw new TooManySubscriptionsError ( response ) ;
61
+ } catch ( e ) {
62
+ assert ( e ) ;
63
+ }
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ const readline = require('readline').createInterface({
9
9
const util = require ( 'util' ) ;
10
10
const path = require ( 'path' ) ;
11
11
const os = require ( 'os' ) ;
12
+ const URL = require ( 'url' ) . URL ;
12
13
13
14
const get = util . promisify ( request . get ) ;
14
15
const post = util . promisify ( request . post ) ;
You can’t perform that action at this time.
0 commit comments