MSMC icon indicating copy to clipboard operation
MSMC copied to clipboard

6.0.0) partial rewrite

Open Hanro50 opened this issue 8 months ago • 3 comments

Done: Removed node-fetch as a dependency Simplified flow Modularized things

Todo: Rewite documentation. Port social features. A ton of bug testing.

Hanro50 avatar Mar 25 '26 17:03 Hanro50

Let me check later - I can take a look this evening

maxheilmann avatar Mar 25 '26 18:03 maxheilmann

I like that the naming is much clearer now!

maxheilmann avatar Mar 25 '26 19:03 maxheilmann

Another thing I thought of is that the errors should maybe be written out in place but have a second property for the translation string, so that there is a default explanation. So that there maybe is a mother error type and all other errors extend that, that mother error class also handles the translation fetching.

Maybe something like this (only poc):

export class MSMCError extends Error {
  public readonly translationKey: string;

  constructor(message: string, translationKey: string) {
    // Look up the key in the map; if undefined or empty, fall back to the provided message
    const resolvedMessage = translationMap[translationKey] || message;
    
    super(resolvedMessage);

    this.name = 'MSMCError';
    this.translationKey = translationKey;

    // Set the prototype explicitly to ensure 'instanceof' works correctly, 
    // especially if you are compiling down to ES5.
    Object.setPrototypeOf(this, MSMCError.prototype);

    // Maintains proper stack trace for where our error was thrown (V8 environments like Node.js / Chrome)
    if (Error.captureStackTrace) {
      Error.captureStackTrace(this, MSMCError);
    }
  }
}

There are also some other conventions on custom js errors in here that I didnt know of myself..

maxheilmann avatar Mar 25 '26 19:03 maxheilmann