Skip to content

Commit b39abc2

Browse files
mergify[bot]paulius-valiunascalebmshafer
authored
return 404 status in RPC when iModel is not open (#3330) (#3333)
* 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]>
1 parent e1dc420 commit b39abc2

File tree

4 files changed

+22
-7
lines changed

4 files changed

+22
-7
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/core-backend",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/core-backend"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@itwin/core-common",
5+
"comment": "",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@itwin/core-common"
10+
}

core/backend/src/rpc-impl/RpcBriefcaseUtility.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ export class RpcBriefcaseUtility {
113113
* @param the IModelRpcProps to locate the opened iModel.
114114
*/
115115
public static async findOpenIModel(accessToken: AccessToken, iModel: IModelRpcProps) {
116-
const iModelDb = IModelDb.tryFindByKey(iModel.key);
117-
if (undefined === iModelDb)
118-
throw new IModelError(IModelStatus.NotOpen, "iModel is not opened", () => iModel);
116+
const iModelDb = IModelDb.findByKey(iModel.key);
119117

120118
// call reattach, just in case this is a V2 checkpoint whose accessToken is about to expire.
121119
await iModelDb.reattachDaemon(accessToken);

core/common/src/rpc/core/RpcInvocation.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,12 @@ export class RpcInvocation {
216216

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

219-
let isNoContentError = false;
220-
try { isNoContentError = reason.errorNumber === IModelStatus.NoContent; } catch { }
221-
222219
if (reason instanceof RpcPendingResponse) {
223220
this._pending = true;
224221
this._threw = false;
225222
result.objects = reason.message;
226223
this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedPending, this);
227-
} else if (this.supportsNoContent() && isNoContentError) {
224+
} else if (this.supportsNoContent() && reason?.errorNumber === IModelStatus.NoContent) {
228225
this._noContent = true;
229226
this._threw = false;
230227
this.protocol.events.raiseEvent(RpcProtocolEvent.BackendReportedNoContent, this);

0 commit comments

Comments
 (0)