Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

try catch

async function promHandler<T>(
  prom: Promise<T>
): Promise<[T | null, any]> {
  try {
    return [await prom, null];
  } catch (error) {
    return [null, error];
  }
}
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #catch
ADD COMMENT
Topic
Name
3+5 =