UdaraJay / Pile

Desktop app for digital journaling.
https://udara.io/pile
MIT License
2.07k stars 111 forks source link

Logging improvements #50

Closed shubhammantri1 closed 10 months ago

shubhammantri1 commented 10 months ago

Thrown error message should be 'Not an HTML/Text content'. It will help to debug the issue with more ease. Also, It'll be helpful if we print contentType to get more clarity.

https://github.com/UdaraJay/Pile/blob/0b37f8c695b45a38423764c88f58d82bf3268f2c/src/main/utils/linkPreview.js#L27

rahulmah5 commented 10 months ago

Would the below help?-

export const getLinkPreview = async (url) => {
  try {
    const response = await axios
      .get(url, {
        headers: {
          Accept: 'text/html',
        },
      })
      .then((response) => {
        const contentType = response.headers['content-type'];
        console.log(contentType);
        if (contentType && contentType.includes('text/html')) {
          return response;
        }
        throw new Error('Not an HTML/Text content');
      });
shubhammantri1 commented 10 months ago

Yes @rahulmah5.

UdaraJay commented 10 months ago

PR it! :)