Skip to content

Commit

Permalink
fix: TS generation of function function and type usage in CodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
beneboy committed Sep 2, 2019
1 parent 3b42dcb commit 2f43bfa
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
8 changes: 8 additions & 0 deletions py/stencila/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,26 @@ 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:
super().__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

Expand Down
6 changes: 6 additions & 0 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
){
Expand All @@ -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
Expand Down
11 changes: 8 additions & 3 deletions schema/CodeError.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion ts/bindings/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 2f43bfa

Please sign in to comment.