diff --git a/py/stencila/schema/types.py b/py/stencila/schema/types.py index 233f86be..d1605785 100644 --- a/py/stencila/schema/types.py +++ b/py/stencila/schema/types.py @@ -292,11 +292,15 @@ def __init__( class CodeError(Entity): """An error that occured when parsing, compiling or executing some Code.""" + kind: str + message: Optional[str] = None trace: Optional[str] = None def __init__( self, + kind: str, id: Optional[str] = None, + message: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, trace: Optional[str] = None ) -> None: @@ -304,6 +308,10 @@ def __init__( id=id, meta=meta ) + if kind is not None: + self.kind = kind + if message is not None: + self.message = message if trace is not None: self.trace = trace diff --git a/r/R/types.R b/r/R/types.R index 3cd57784..d9631ecf 100644 --- a/r/R/types.R +++ b/r/R/types.R @@ -321,13 +321,17 @@ CodeExpression <- function( #' An error that occured when parsing, compiling or executing some Code. #' #' @name CodeError +#' @param kind The type of error. \bold{Required}. #' @param id The identifier for this item. +#' @param message The error message or brief description of the error. #' @param meta Metadata associated with this item. #' @param trace Stack trace leading up to the error. #' @seealso \code{\link{Entity}} #' @export CodeError <- function( + kind, id, + message, meta, trace ){ @@ -336,6 +340,8 @@ CodeError <- function( meta = meta ) self$type <- as_scalar("CodeError") + self[["kind"]] <- check_property("CodeError", "kind", TRUE, missing(kind), "character", kind) + self[["message"]] <- check_property("CodeError", "message", FALSE, missing(message), "character", message) self[["trace"]] <- check_property("CodeError", "trace", FALSE, missing(trace), "character", trace) class(self) <- c("list", "Entity") self diff --git a/schema/CodeError.schema.yaml b/schema/CodeError.schema.yaml index 1df593b7..082eafcf 100644 --- a/schema/CodeError.schema.yaml +++ b/schema/CodeError.schema.yaml @@ -6,13 +6,18 @@ status: unstable category: code description: An error that occured when parsing, compiling or executing some Code. properties: - type: - '@id': stencila:errorType + kind: + # not called `type` because this is a conflict or not supported by Python + '@id': stencila:errorKind description: The type of error. type: string + message: + '@id': stencila:errorMessage + description: The error message or brief description of the error. + type: string trace: '@id': stencila:trace description: Stack trace leading up to the error. type: string required: - - type + - kind diff --git a/ts/bindings/typescript.ts b/ts/bindings/typescript.ts index 5b856331..27f105c4 100644 --- a/ts/bindings/typescript.ts +++ b/ts/bindings/typescript.ts @@ -151,7 +151,10 @@ export const unionGenerator = (schema: Schema): string => { */ const funcName = (name: string): string => { const func = `${name.substring(0, 1).toLowerCase() + name.substring(1)}` - const reserved: { [key: string]: string } = { delete: 'del' } + const reserved: { [key: string]: string } = { + delete: 'del', + function: 'function_' + } if (reserved[func] !== undefined) return reserved[func] else return func }