Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js error handling

// ES2022

function readFiles(filePaths) {
  return filePaths.map(
    (filePath) => {
      try {
        // ···
      } catch (error) {
        throw new Error(
          `While processing ${filePath}`,
          {cause: error}
        );
      }
    });
}

// For more: https://2ality.com/2021/06/error-cause.html
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #js #error #handling
ADD COMMENT
Topic
Name
5+1 =