Skip to content

Commit

Permalink
Merge pull request #10 from luk3Sky/main
Browse files Browse the repository at this point in the history
More TypeError fixes
  • Loading branch information
luk3Sky authored Jan 16, 2021
2 parents 05a475f + 035c9d4 commit 8dcefc4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export const resolveChannelTopic = (topic: string) => {
const mergedTopic = channel + topic;
var result: string;
if (typeof topic !== 'string') {
throw new TypeError('Invalid topic');
console.error('Invalid topic');
return channel;
} else {
const mergedFC = channel + topic[0];
if (channel.includes('/') && topic[0].includes('/')) {
Expand Down
2 changes: 1 addition & 1 deletion src/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class Queue implements AbstractQueue {
*/
remove = (topic: string) => {
if (typeof topic !== 'string') {
throw new TypeError('Invalid topic');
console.error('Invalid topic');
} else {
const prevList = this._list;
prevList.forEach((item, index) => {
Expand Down
6 changes: 3 additions & 3 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class MQTTRouter {
}
try {
msg =
this._routes[i].type == 'String'
this._routes[i].type === 'String'
? message.toString()
: JSON.parse(message.toString());
/*msg = message.toString();
Expand Down Expand Up @@ -277,7 +277,7 @@ export class MQTTRouter {
*/
addRoute = (route: Route) => {
if (route === undefined) {
throw new TypeError('Invalid route');
console.error('Invalid route');
} else {
this._routes.push(route);
if (route.subscribe !== false) {
Expand Down Expand Up @@ -307,7 +307,7 @@ export class MQTTRouter {
*/
removeRoute = (topic: string) => {
if (topic === undefined) {
throw new TypeError('Invalid topic');
console.error('Invalid topic');
} else {
const prevList = this._routes;
prevList.forEach((item, index) => {
Expand Down

0 comments on commit 8dcefc4

Please sign in to comment.