mirror of
https://github.com/denoland/deno.git
synced 2025-01-21 13:00:36 -05:00
move suggestion to runtime/format_errors.rs
- https://github.com/denoland/deno/pull/25517#discussion_r1801666281 - https://github.com/denoland/deno/pull/25517#discussion_r1801666872
This commit is contained in:
parent
40c89cc30a
commit
ad67750587
2 changed files with 24 additions and 8 deletions
|
@ -262,20 +262,14 @@ function createImageBitmap(
|
||||||
} else if (mimeTypeString === "") {
|
} else if (mimeTypeString === "") {
|
||||||
return PromiseReject(
|
return PromiseReject(
|
||||||
new DOMException(
|
new DOMException(
|
||||||
`The MIME type of source image is not specified.
|
`The MIME type of source image is not specified.`,
|
||||||
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",
|
"InvalidStateError",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return PromiseReject(
|
return PromiseReject(
|
||||||
new DOMException(
|
new DOMException(
|
||||||
`The the MIME type ${mimeTypeString} of source image is not a supported format.
|
`The MIME type ${mimeTypeString} of source image is not a supported format.`,
|
||||||
info: The following MIME types are supported:
|
|
||||||
https://mimesniff.spec.whatwg.org/#image-type-pattern-matching-algorithm\n`,
|
|
||||||
"InvalidStateError",
|
"InvalidStateError",
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -404,6 +404,28 @@ fn get_suggestions_for_terminal_errors(e: &JsError) -> Vec<FixSuggestion> {
|
||||||
]),
|
]),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
// 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 <u>Blob</> from <u>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 <u>await(await fetch('http://localhost:8000/sample.png').blob()</>."),
|
||||||
|
cstr!("Alternatively, if you are reading a local file using <u>Deno.readFile</> etc.,"),
|
||||||
|
cstr!("set the appropriate MIME type like <u>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![]
|
vec![]
|
||||||
|
|
Loading…
Add table
Reference in a new issue