Skip to content

Commit b07b634

Browse files
committed
fix(api): improve error handling by throwing errors directly instead of processing them conditionally
1 parent 676fab9 commit b07b634

File tree

1 file changed

+2
-15
lines changed
  • apps/meteor/app/api/server/v1

1 file changed

+2
-15
lines changed

apps/meteor/app/api/server/v1/misc.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import crypto from 'crypto';
22

3+
import { MeteorError } from '@rocket.chat/core-services';
34
import type { IUser } from '@rocket.chat/core-typings';
45
import { Settings, Users, WorkspaceCredentials } from '@rocket.chat/models';
56
import {
@@ -526,21 +527,7 @@ API.v1.addRoute(
526527
Meteor._debug(`Exception while invoking method ${method}`, err);
527528
}
528529

529-
if (err instanceof Meteor.Error) {
530-
switch (err.error) {
531-
case 'error-too-many-requests':
532-
return API.v1.tooManyRequests(mountResult({ id, error: err }));
533-
case 'unauthorized':
534-
case 'error-unauthorized':
535-
return API.v1.unauthorized(mountResult({ id, error: err }));
536-
case 'forbidden':
537-
case 'error-forbidden':
538-
return API.v1.forbidden(mountResult({ id, error: err }));
539-
default:
540-
return API.v1.failure(mountResult({ id, error: err }));
541-
}
542-
}
543-
return API.v1.failure(mountResult({ id, error: err }));
530+
throw err;
544531
}
545532
},
546533
},

0 commit comments

Comments
 (0)