Skip to content

[Tizen.Applications.Common] Consolidate repeated ErrorCode switch blocks into MapContextError helper#7565

Open
JoonghyunCho wants to merge 1 commit intomainfrom
ai-task/issue-7564
Open

[Tizen.Applications.Common] Consolidate repeated ErrorCode switch blocks into MapContextError helper#7565
JoonghyunCho wants to merge 1 commit intomainfrom
ai-task/issue-7564

Conversation

@JoonghyunCho
Copy link
Copy Markdown
Member

Closes #7564

Summary

Replaces 5 near-identical switch (err) blocks in ApplicationRunningContext.cs with a single private helper method MapContextError that uses a C# switch expression.

Before (repeated 5×, two variants):

switch (err)
{
    case Interop.ApplicationManager.ErrorCode.InvalidParameter:
        throw new ArgumentException("Invalid Parameter.");
    case Interop.ApplicationManager.ErrorCode.NoSuchApp:
        throw new InvalidOperationException("No such application.");
    case Interop.ApplicationManager.ErrorCode.OutOfMemory:
        throw new OutOfMemoryException("Out of memory");
    default:
        throw new InvalidOperationException("Invalid Operation.");
}

After (each call site):

throw MapContextError(err);

Helper (single definition, covers all cases):

private static Exception MapContextError(Interop.ApplicationManager.ErrorCode err) => err switch
{
    Interop.ApplicationManager.ErrorCode.InvalidParameter => new ArgumentException("Invalid Parameter."),
    Interop.ApplicationManager.ErrorCode.NoSuchApp        => new InvalidOperationException("No such application."),
    Interop.ApplicationManager.ErrorCode.OutOfMemory      => new OutOfMemoryException("Out of memory"),
    Interop.ApplicationManager.ErrorCode.PermissionDenied => new UnauthorizedAccessException("Permission denied."),
    _                                                      => new InvalidOperationException("Invalid Operation."),
};

Changes

  • ApplicationRunningContext.cs: -49 lines / +14 lines (net -35)
  • No public API changes; purely internal refactoring
  • Build: 0 errors, 4 pre-existing warnings (unchanged)

Benchmark

Device benchmark skipped — no sdb target available in build environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-task API14 Platform : Tizen 11.0 / TFM: net8.0-tizen11.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[AI Refactoring] ApplicationRunningContext 반복 switch 블록 → C# switch expression 헬퍼 통합

1 participant