generate exceptions in implementation

This commit is contained in:
2021-12-02 11:59:10 +01:00
parent fe9c431999
commit c9e54aebc8
7 changed files with 68 additions and 9 deletions

View File

@ -117,15 +117,31 @@ null#slurp
[0]#slurp
#end if
);
} catch (NotDataFoundException) {
\#pragma warning disable CS0168
#for $errDef in $Exceptions
} catch ($errDef['Exception'] ex) {
var err = new ErrorResultObject();
err.errorCode = 400;
err.serviceErrorCode = 517;
err.errorMessage("item not found");
err.errorInfoURL("https://google.com");
return BadRequest(err);
}
err.ErrorCode = $errDef['ErrorCode'];
err.ServiceErrorCode = $errDef['ServiceErrorCode'];
err.ErrorMessage = #slurp
#if $errDef['ErrorMessage'] == 'INSERT_EXCEPTION_MESSAGE'
ex.ToString();
#else
"$errDef['ErrorMessage']";
#end if
err.ErrorInfoURL = "$errDef['ErrorInfoURL']";
err.OffensiveData = #slurp
#if $operation['bodyInputType']
Newtonsoft.Json.JsonConvert.SerializeObject($operation['bodyInputType']['apiName'], Newtonsoft.Json.Formatting.Indented);
#elif $operation['paramInputTypes']
Newtonsoft.Json.JsonConvert.SerializeObject(paramInput, Newtonsoft.Json.Formatting.Indented);
#else
null;
#end if
return StatusCode($errDef['ErrorCode'], err);
#end for
}
\#pragma warning restore CS0168
}
#elif $operation['method'] == 'post'