You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
query(query,params){constc=this.connection;constlocalErr=newError();if(typeofparams==='function'){thrownewError('Callback function is not available with promise clients.');}returnnewthis.Promise((resolve,reject)=>{constdone=makeDoneCb(resolve,reject,localErr);if(params!==undefined){c.query(query,params,done);}else{c.query(query,done);}});}
Why we not define some kind of subclass for this and type it properly in TypeScript?
Something like:
classMySqlErrorextendsError{constructor(message,options={}){super(message);this.name='MySqlError';// Copy extra properties from the MySQL2 errorObject.assign(this,options);}}interfaceMySqlErrorextendsError{code?: string;errno?: number;sqlState?: string;sqlMessage?: string;sql?: string;}
Usage of current error implementation is very hacky in the TS project.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Example of the current implementation:
Why we not define some kind of subclass for this and type it properly in TypeScript?
Something like:
Usage of current error implementation is very hacky in the TS project.
Beta Was this translation helpful? Give feedback.
All reactions