importMyCustomExceptionfrom'./MyCustomException';constInspector=require('inspector-with-exceptions');constvalue=null;/** * Some logic */try{Inspector.isNumber(value,'Must be a number',MyCustomException);}catch(e){if(einstanceofMyCustomException){console.log('MyCustomException');}}