From 6453b7fe54dae8144c748a77a2ab765d2afeb703 Mon Sep 17 00:00:00 2001 From: Hajime-san <41257923+Hajime-san@users.noreply.github.com> Date: Sat, 7 Dec 2024 18:59:44 +0900 Subject: [PATCH] Revert move suggestion to `runtime/fmt_errors.rs` --- ext/canvas/01_image.js | 10 ++++++++-- runtime/fmt_errors.rs | 22 ---------------------- 2 files changed, 8 insertions(+), 24 deletions(-) diff --git a/ext/canvas/01_image.js b/ext/canvas/01_image.js index 4afce03146..75ec1b80f9 100644 --- a/ext/canvas/01_image.js +++ b/ext/canvas/01_image.js @@ -267,14 +267,20 @@ function createImageBitmap( } else if (mimeTypeString === "") { return PromiseReject( new DOMException( - `The MIME type of source image is not specified`, + `The MIME type of source image is not specified\n +hint: When you want to get a "Blob" from "fetch", make sure to go through a file server that returns the appropriate content-type response header, + and specify the URL to the file server like "await(await fetch('http://localhost:8000/sample.png').blob()". + Alternatively, if you are reading a local file using 'Deno.readFile' etc., + set the appropriate MIME type like "new Blob([await Deno.readFile('sample.png')], { type: 'image/png' })".\n`, "InvalidStateError", ), ); } else { return PromiseReject( new DOMException( - `The MIME type ${mimeTypeString} of source image is not a supported format`, + `The the MIME type ${mimeTypeString} of source image is not a supported format\n +info: The following MIME types are supported. +docs: https://mimesniff.spec.whatwg.org/#image-type-pattern-matching-algorithm\n`, "InvalidStateError", ), ); diff --git a/runtime/fmt_errors.rs b/runtime/fmt_errors.rs index e04b2e988c..6f120b5d46 100644 --- a/runtime/fmt_errors.rs +++ b/runtime/fmt_errors.rs @@ -458,28 +458,6 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec { ]), ]; } - // See: ext/canvas/01_image.js - else if msg.contains("The MIME type of source image is not specified") { - return vec![ - FixSuggestion::hint_multiline(&[ - cstr!("When you want to get a Blob from fetch, make sure to go through a file server that returns the appropriate content-type response header,"), - cstr!("and specify the URL to the file server like await(await fetch('http://localhost:8000/sample.png').blob()."), - cstr!("Alternatively, if you are reading a local file using Deno.readFile etc.,"), - cstr!("set the appropriate MIME type like new Blob([await Deno.readFile('sample.png')], { type: 'image/png' }).") - ]), - ]; - } - // See: ext/canvas/01_image.js - else if msg.contains("The MIME type") - && msg.contains("of source image is not a supported format") - { - return vec![ - FixSuggestion::info( - "The following MIME types are supported." - ), - FixSuggestion::docs("https://mimesniff.spec.whatwg.org/#image-type-pattern-matching-algorithm"), - ]; - } } vec![]