Skip to content

Commit

Permalink
return 404 status in RPC when iModel is not open (#3330) (#3333)
Browse files Browse the repository at this point in the history
* return 404 status in RPC when iModel is not open

* remove redundant throw

* remove unused import

(cherry picked from commit 71e8a16)

Co-authored-by: Paulius Valiūnas <[email protected]>
Co-authored-by: Caleb Shafer <[email protected]>
  • Loading branch information
3 people authored Mar 10, 2022
1 parent e1dc420 commit b39abc2
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-backend",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-backend"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-common",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-common"
}
4 changes: 1 addition & 3 deletions core/backend/src/rpc-impl/RpcBriefcaseUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ export class RpcBriefcaseUtility {
* @param the IModelRpcProps to locate the opened iModel.
*/
public static async findOpenIModel(accessToken: AccessToken, iModel: IModelRpcProps) {
const iModelDb = IModelDb.tryFindByKey(iModel.key);
if (undefined === iModelDb)
throw new IModelError(IModelStatus.NotOpen, "iModel is not opened", () => iModel);
const iModelDb = IModelDb.findByKey(iModel.key);

// call reattach, just in case this is a V2 checkpoint whose accessToken is about to expire.
await iModelDb.reattachDaemon(accessToken);
Expand Down
5 changes: 1 addition & 4 deletions core/common/src/rpc/core/RpcInvocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,12 @@ export class RpcInvocation {

const result = await RpcMarshaling.serialize(this.protocol, reason);

let isNoContentError = false;
try { isNoContentError = reason.errorNumber === IModelStatus.NoContent; } catch { }

if (reason instanceof RpcPendingResponse) {
this._pending = true;
this._threw = false;
result.objects = reason.message;
this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);
} else if (this.supportsNoContent() && isNoContentError) {
} else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {
this._noContent = true;
this._threw = false;
this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);
Expand Down

0 comments on commit b39abc2

Please sign in to comment.