summaryrefslogtreecommitdiff
path: root/cli/ops
diff options
context:
space:
mode:
Diffstat (limited to 'cli/ops')
-rw-r--r--cli/ops/dispatch_minimal.rs4
-rw-r--r--cli/ops/files.rs2
-rw-r--r--cli/ops/worker_host.rs29
3 files changed, 18 insertions, 17 deletions
diff --git a/cli/ops/dispatch_minimal.rs b/cli/ops/dispatch_minimal.rs
index 70c4af6c3..0bff571f2 100644
--- a/cli/ops/dispatch_minimal.rs
+++ b/cli/ops/dispatch_minimal.rs
@@ -4,8 +4,8 @@
//! alternative to flatbuffers using a very simple list of int32s to lay out
//! messages. The first i32 is used to determine if a message a flatbuffer
//! message or a "minimal" message.
+use crate::deno_error::ErrorKind;
use crate::deno_error::GetErrorKind;
-use crate::msg::ErrorKind;
use byteorder::{LittleEndian, WriteBytesExt};
use deno_core::Buf;
use deno_core::CoreOp;
@@ -124,7 +124,7 @@ where
let error_record = ErrorRecord {
promise_id: 0,
arg: -1,
- error_code: ErrorKind::InvalidInput as i32,
+ error_code: ErrorKind::TypeError as i32,
error_message: "Unparsable control buffer"
.to_string()
.as_bytes()
diff --git a/cli/ops/files.rs b/cli/ops/files.rs
index d625d4590..9619051a7 100644
--- a/cli/ops/files.rs
+++ b/cli/ops/files.rs
@@ -190,7 +190,7 @@ fn op_seek(
2 => SeekFrom::End(i64::from(offset)),
_ => {
return Err(ErrBox::from(DenoError::new(
- ErrorKind::InvalidSeekMode,
+ ErrorKind::TypeError,
format!("Invalid seek mode: {}", whence),
)));
}
diff --git a/cli/ops/worker_host.rs b/cli/ops/worker_host.rs
index 13d4fffff..c3b907673 100644
--- a/cli/ops/worker_host.rs
+++ b/cli/ops/worker_host.rs
@@ -2,7 +2,6 @@
use super::dispatch_json::{Deserialize, JsonOp, Value};
use crate::deno_error::DenoError;
use crate::deno_error::ErrorKind;
-use crate::deno_error::GetErrorKind;
use crate::fmt_errors::JSError;
use crate::futures::SinkExt;
use crate::global_state::GlobalState;
@@ -212,11 +211,17 @@ fn op_host_terminate_worker(
fn serialize_worker_event(event: WorkerEvent) -> Value {
match event {
WorkerEvent::Message(buf) => json!({ "type": "msg", "data": buf }),
- WorkerEvent::Error(error) => match error.kind() {
- ErrorKind::JSError => {
- let error = error.downcast::<JSError>().unwrap();
- let exception: V8Exception = error.into();
- json!({
+ WorkerEvent::Error(error) => {
+ let mut serialized_error = json!({
+ "type": "error",
+ "error": {
+ "message": error.to_string(),
+ }
+ });
+
+ if let Ok(err) = error.downcast::<JSError>() {
+ let exception: V8Exception = err.into();
+ serialized_error = json!({
"type": "error",
"error": {
"message": exception.message,
@@ -224,15 +229,11 @@ fn serialize_worker_event(event: WorkerEvent) -> Value {
"lineNumber": exception.line_number,
"columnNumber": exception.start_column,
}
- })
+ });
}
- _ => json!({
- "type": "error",
- "error": {
- "message": error.to_string(),
- }
- }),
- },
+
+ serialized_error
+ }
}
}