38 lines
1019 B
Nim
38 lines
1019 B
Nim
import jester, strutils
|
|
|
|
type
|
|
ApiError* = object of CatchableError
|
|
respMsg*: string
|
|
respCode*: HttpCode
|
|
|
|
HffEntryFormsApiConfig* = ref object
|
|
debug*: bool
|
|
eventParentId*: string
|
|
integrationToken*: string
|
|
knownOrigins*: seq[string]
|
|
notionApiBaseUrl*: string
|
|
notionVersion*: string
|
|
port*: int
|
|
|
|
proc newApiError*(parent: ref Exception = nil, respCode: HttpCode, respMsg: string, msg = ""): ref ApiError =
|
|
result = newException(ApiError, msg, parent)
|
|
result.respCode = respCode
|
|
result.respMsg = respMsg
|
|
|
|
proc raiseApiError*(respCode: HttpCode, respMsg: string, msg = "") =
|
|
var apiError = newApiError(
|
|
parent = nil,
|
|
respCode = respCode,
|
|
respMsg = respMsg,
|
|
msg = if msg.isEmptyOrWhitespace: respMsg
|
|
else: msg)
|
|
raise apiError
|
|
|
|
proc raiseApiError*(parent: ref Exception, respCode: HttpCode, respMsg: string, msg = "") =
|
|
var apiError = newApiError(
|
|
parent = parent,
|
|
respCode = respCode,
|
|
respMsg = respMsg,
|
|
msg = msg)
|
|
raise apiError
|