0

I am a beginner.

I don't know How to catch the number of this error in JS with a try-catch, I'm lost.

Uncaught (in promise)
no: 6, message: "PNG driver doesn't support data type Int16. Only e…bit (UInt16) bands supported. Defaulting to Byte\n"}
message: "PNG driver doesn't support data type Int16. Only eight bit (Byte) and sixteen bit (UInt16) bands supported. Defaulting to Byte\n"
no: 6

Please, Help Me :)

kakou
  • 3
  • 1
  • 1
    Please [edit] your question post the code that is causing this error, and show us how you used `try`/`catch`. We can't help you without that. – Bergi Jul 29 '22 at 16:30
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jul 31 '22 at 05:20
  • @Bergi here is a part of my code, i want to catch the error to change options[] params : `try { options = [ '-of', 'PNG' ]; GDAL.gdal_translate(tifDataset, options).then((output) => { GDAL.getFileBytes(output).then((bytes) =>{ base64Data = btoa(bytes.toString().split(',').map(c => String.fromCharCode(c)).join('')); }); }); }` – kakou Aug 01 '22 at 08:04
  • @kakou What is `GDAL`? Please [edit] your question to include the code with proper formatting – Bergi Aug 01 '22 at 19:50
  • And yes, you cannot handle asynchronous errors (promise rejection) with `try`/`catch` unless you use `async`/`await`, see https://stackoverflow.com/questions/44663864/correct-try-catch-syntax-using-async-await or https://stackoverflow.com/questions/40884153/try-catch-blocks-with-async-await. This question is probably a duplicate of https://stackoverflow.com/questions/68102365/why-is-try-catch-not-working-with-async-await-function – Bergi Aug 01 '22 at 19:51
  • @Bergi GDAL is a librairy. It allows me to convert TIFF images to PNG. – kakou Aug 02 '22 at 07:37
  • @Bergi thank you for your answer I'll try ```async```/```await```. I hope it works – kakou Aug 02 '22 at 07:39

0 Answers0